package com.car.web.controller.index;

import java.awt.Color;
import java.io.File;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.net.URLEncoder;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.car.dal.dao.client.TgClientDao;
import com.car.dal.dao.client.TgClientImpDao;
import com.car.dal.dao.department.TgDepartmentDao;
import com.car.dal.dao.from.FromUserDao;
import com.car.dal.dao.office.TgOfficeDao;
import com.car.dal.dao.reception.TgReceptionDao;
import com.car.dal.dao.reserve.TgReserveDao;
import com.car.dal.dao.source.TgSourceDao;
import com.car.dal.dao.tracking.TgTrackingDao;
import com.car.dal.dao.user.UserDao;
import com.car.dal.dao.user.UserinfoDao;
import com.car.dal.dao.usergroup.TgUsergroupDao;
import com.car.dal.dao.vote.JsVoteDao;
import com.car.dal.object.BetimesStatis;
import com.car.dal.object.CityWenjuan;
import com.car.dal.object.JingJia;
import com.car.dal.object.JsFromUser;
import com.car.dal.object.JsVote;
import com.car.dal.object.QuDao;
import com.car.dal.object.Record;
import com.car.dal.object.TgClient;
import com.car.dal.object.TgClientImp;
import com.car.dal.object.TgOffice;
import com.car.dal.object.TgReception;
import com.car.dal.object.TgReserve;
import com.car.dal.object.TgSource;
import com.car.dal.object.TgTracking;
import com.car.dal.object.TgUser;
import com.car.dal.object.TgUserinfo;
import com.car.exception.BaseException;
import com.car.service.reception.ReceptionService;
import com.car.util.Constants;
import com.car.util.DateUtil;
import com.car.util.Page;
import com.car.util.PageUtil;
import com.car.util.Result;
import com.car.util.ResultSupport;
import com.car.util.UserUtil;
import com.car.util.WebExecutor;
import com.car.util.WebExecutor.Biz;
import com.car.web.controller.base.BaseController;
import com.car.web.controller.base.BaseVo;

/**
 * 登录控制
 * 
 * @author Administrator
 * 
 */
@Controller
@RequestMapping("/statis")
public class StatisController extends BaseController {

	private static final Logger logger = Logger
			.getLogger(StatisController.class);
	@Resource
	private UserDao userDao;
	@Resource
	private TgUsergroupDao tgUsergroupDao;
	@Resource
	private TgDepartmentDao tgDepartmentDao;
	@Resource
	private UserinfoDao userinfoDao;
	@Resource
	private TgClientImpDao clientImpDao;
	@Resource
	private TgOfficeDao tgOfficeDao;
	@Resource
	private TgSourceDao sourceDao;
	@Resource
	private TgTrackingDao trackingDao;
	@Resource
	private JsVoteDao voteDao;
	@Resource
	private TgClientDao clientDao;
	@Resource
	private TgReserveDao reserveDao;
	@Resource
	private TgReceptionDao receptionDao;
	@Resource
	private FromUserDao fromUserDao;
	@Resource
    private ReceptionService receptionService;

	// 及时分配统计--推广部门个人统计
	@RequestMapping(value = "/consultant_fenpei_betimes")
	public ModelAndView consultant_fenpei_betimes(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String startTime = request.getParameter("startTime");
					String endTime = request.getParameter("endTime");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

					if (startTime != null && !"".equals(startTime)) {
					} else {
						startTime = sdf.format(new Date());
					}
					result.setDefaultModel("startTime", startTime);
					result.setDefaultModel("endTime", endTime);

					if (endTime != null && !"".equals(endTime)) {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(endTime)));
					} else {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(startTime)));
					}

					BetimesStatis betimes = new BetimesStatis();
					TgUser user = UserUtil.getUserFromCookies();
					if (user == null) {
						return result;
					}
					TgClientImp clientImp = new TgClientImp();
					clientImp.setUsername(user.getUsername());
					clientImp.setStartTime(startTime);
					clientImp.setEndTime(endTime);
					List<TgClientImp> clientImpList = clientImpDao
							.getClientImpByType(clientImp);
					betimes.setZonCount(clientImpList.size() + "");
					if (clientImpList != null && clientImpList.size() > 0) {
						Integer yifpCount = 0;
						Integer weifpCount = 0;
						Integer yanshiCount = 0;
						Integer jishiCount = 0;
						for (TgClientImp imp : clientImpList) {
							if (imp.getTo_time() != null
									&& !"".equals(imp.getTo_time())) {
								yifpCount++;
								Long time = imp.getTo_time().getTime()
										- imp.getCreate_time().getTime();
								if (time > 600000) {
									yanshiCount++;
								} else {
									jishiCount++;
								}
							} else {
								weifpCount++;
							}
						}
						betimes.setYifpCount(yifpCount + "");
						betimes.setWeifpCount(weifpCount + "");
						betimes.setJishiCount(jishiCount + "");
						betimes.setYanshiCount(yanshiCount + "");
					}
					result.setDefaultModel("betimes", betimes);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("consultant/statis/consultant_fenpei_betimes",
				modelMap);
	}

	@RequestMapping(value = "/consultant_fenpei_estimate")
	public ModelAndView consultant_fenpei_estimate(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String startTime = request.getParameter("startTime");
					String endTime = request.getParameter("endTime");
					String region = request.getParameter("region");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

					if (startTime != null && !"".equals(startTime)) {
					} else {
						startTime = sdf.format(new Date());
					}
					result.setDefaultModel("startTime", startTime);
					result.setDefaultModel("endTime", endTime);
					result.setDefaultModel("region", region);

					if (endTime != null && !"".equals(endTime)) {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(endTime)));
					} else {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(startTime)));
					}

					TgUserinfo user = new TgUserinfo();
					user.setJob("课程顾问");
					if (region != null && !"".equals(region)) {
						user.setRegion(region);
					}
					List<TgUserinfo> uList = userinfoDao
							.getUserInfoByUserInfo(user);
					TgClientImp clientImp = new TgClientImp();
					TgOffice center = new TgOffice();
					if (uList != null && uList.size() > 0) {
						for (TgUserinfo info : uList) {
							clientImp.setTo_username(info.getUsername());
							clientImp.setStartTime(startTime);
							clientImp.setEndTime(endTime);
							Integer count = clientImpDao
									.getClientImpCountByType(clientImp);
							info.setTea_toCount(count);

							center.setKeyname(info.getRegion());
							List<TgOffice> cenList = tgOfficeDao
									.findByExample(center);
							if (cenList != null && cenList.size() > 0) {
								String regions = cenList.get(0).getName();
								info.setRegions(regions);
							}
						}
					}

					List<TgOffice> centerList = tgOfficeDao
							.findAll(TgOffice.class);

					result.setDefaultModel("uList", uList);
					result.setDefaultModel("centerList", centerList);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("consultant/statis/consultant_fenpei_estimate",
				modelMap);
	}
	@RequestMapping(value = "/system_qudao_statis")
	public ModelAndView system_qudao_statis(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, final HttpServletResponse response)
			throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String startTime = request.getParameter("startTime");
					String endTime = request.getParameter("endTime");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

					if (startTime != null && !"".equals(startTime)) {
					} else {
						startTime = sdf.format(new Date());
					}
					result.setDefaultModel("startTime", startTime);
					result.setDefaultModel("endTime", endTime);

					if (endTime != null && !"".equals(endTime)) {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(endTime)));
					} else {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(startTime)));
					}

					List<TgSource> list = sourceDao.findAll(TgSource.class);
					if (list != null && list.size() > 0) {
						for (TgSource source : list) {
							TgClientImp clientImp = new TgClientImp();
							clientImp.setStartTime(startTime);
							clientImp.setEndTime(endTime);
							clientImp.setType(source.getKeyname());
							List<TgClientImp> clientImpList = clientImpDao
									.getClientImpByType(clientImp);
							source.setZonCount(clientImpList.size() + "");
							if (clientImpList != null
									&& clientImpList.size() > 0) {
								Integer cfuCount = 0;
								for (TgClientImp imp : clientImpList) {
									if (imp.getColor() != null
											&& !"".equals(imp.getColor())) {
										cfuCount++;
									}
								}
								source.setCfuCount(cfuCount + "");
							}

						}
					}

					result.setDefaultModel("list", list);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("system/statis/system_qudao_statis", modelMap);
	}
	/**
	 * 新每日资源统计
	 */
	@RequestMapping(value = "/system_qudao_statis3")
	public ModelAndView system_qudao_statis3(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String time = request.getParameter("time");
					SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
	
					if (time == null || time.equals("")) {
						time = sd.format(new Date());
					}
				//	List<QuDao> qdList = new ArrayList<QuDao>();
					//获取这一周的日期
					List<String> list_date = DateUtil.printWeekdays(time);
					
					JsVote vote = new JsVote();
					/*List<JsVote> zonwj = null;
					List<JsFromUser> zonfrom = null;
					List<TgClientImp> zoncilent = null;
					List<String> slist = new ArrayList<String>();
					Map<String,String> map = new HashMap<>();*/
					/**
					 * 查询出来的数据
					 */
					List<String> slist_vote = new ArrayList<String>();
					Integer vote_hj = 0;
					for (int i = 0; i < list_date.size(); i++) {
						//(1)
						Long tommorrow = DateUtil.getTommorrowDay1(sd.parse(list_date.get(i))).getTime() / 1000;
						vote.setStartTime(sd.parse(list_date.get(i)).getTime() / 1000);
						vote.setEndTime(tommorrow);
						//(2)
						String tommorrow_1 = sd.format(DateUtil.getTommorrowDay1(sd.parse(list_date.get(i))));
						vote.setStartTime_1(list_date.get(i).toString());
						vote.setEndTime_1(tommorrow_1);
						
						//slist_vote = voteDao.getVoteTjiByType3(vote);
						slist_vote = voteDao.getVoteTj_New(vote);
						vote_hj = voteDao.getVoteTjiByType_sum(vote);
						switch (i) {
							case 0:
								result.setDefaultModel("slist_0", slist_vote);
								result.setDefaultModel("vote_hj_0", vote_hj);
								break;
							case 1:
								result.setDefaultModel("slist_1", slist_vote);
								result.setDefaultModel("vote_hj_1", vote_hj);
								break;
							case 2:
								result.setDefaultModel("slist_2", slist_vote);
								result.setDefaultModel("vote_hj_2", vote_hj);
								break;
							case 3:
								result.setDefaultModel("slist_3", slist_vote);
								result.setDefaultModel("vote_hj_3", vote_hj);
								break;
							case 4:
								result.setDefaultModel("slist_4", slist_vote);
								result.setDefaultModel("vote_hj_4", vote_hj);
								break;
							case 5:
								result.setDefaultModel("slist_5", slist_vote);
								result.setDefaultModel("vote_hj_5", vote_hj);
								break;
							case 6:
								result.setDefaultModel("slist_6", slist_vote);
								result.setDefaultModel("vote_hj_6", vote_hj);
								break;
						}
					}
					/**
					 * 获取重复的数据（一人使用多渠道）
					 */
					vote.setStartTime(sd.parse(list_date.get(0)).getTime() / 1000);//周一的日期
					vote.setEndTime(sd.parse(list_date.get(6)).getTime() / 1000);//周末的日期
					List<String> chongFu = voteDao.getVoteTjiByType_chongFu(vote);
					if(chongFu != null && chongFu.size()>0) {
						for(Object obj:chongFu) {
							System.out.println(obj);
						}
						result.setDefaultModel("chongFu", chongFu);
					}
					result.setDefaultModel("list_date", list_date);
					result.setDefaultModel("time", time);
				} catch (ParseException e) {
					e.printStackTrace();
				}
				return result;
			}
		});
		return new ModelAndView("system/statis/system_qudao_statis3", modelMap);
	}	
	@RequestMapping(value = "/system_qudao_statis2")
	public ModelAndView system_qudao_statis2(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String time = request.getParameter("time");
					SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");

					if (time == null || time.equals("")) {
						time = sd.format(new Date());
					}

					List<QuDao> qdList = new ArrayList<QuDao>();
					List<String> list = DateUtil.printWeekdays(time);

					JsVote vote = new JsVote();
					JsVote vote2 = new JsVote();
					TgClientImp client = new TgClientImp();
					TgClientImp client2 = new TgClientImp();
					JsFromUser fromUser = new JsFromUser();
					JsFromUser fromUser2 = new JsFromUser();

					QuDao qd0 = new QuDao();
					QuDao qd1 = new QuDao();
					QuDao qd2 = new QuDao();
					QuDao qd3 = new QuDao();
					QuDao qd4 = new QuDao();
					QuDao qd5 = new QuDao();
					QuDao qd6 = new QuDao();
					QuDao qd7 = new QuDao();
					QuDao qd8 = new QuDao();
					QuDao qd9 = new QuDao();
					QuDao qd10 = new QuDao();
					QuDao qd11 = new QuDao();
					QuDao qd12 = new QuDao();
					QuDao qd13 = new QuDao();
					QuDao qd14 = new QuDao();
					QuDao qd15 = new QuDao();
					QuDao qd16 = new QuDao();
					QuDao qd17 = new QuDao();
					QuDao qd18 = new QuDao();
					QuDao qd19 = new QuDao();
					QuDao qd20 = new QuDao();
					QuDao qd21 = new QuDao();
					QuDao qd22 = new QuDao();
					

					List<JsVote> zonwj = null;
					List<JsFromUser> zonfrom = null;
					List<TgClientImp> zoncilent = null;
					List<String> slist = new ArrayList<String>();
					for (int i = 0; i < list.size(); i++) {

						Long tommorrow = DateUtil.getTommorrowDay1(
								sd.parse(list.get(i))).getTime() / 1000;

						vote.setStartTime(sd.parse(list.get(i)).getTime() / 1000);
						vote.setEndTime(tommorrow);
						
						
						
						// vote.setAsk_cn(0);

						// 总共问卷
						vote.setSource("");
						zonwj = voteDao.getVoteTjiByType(vote);

						// 手机问卷
						vote.setSource("l6xdybjjrcjc");
						Integer sj = voteDao.getVoteTjiByType2(vote);

						// 网站问卷
						vote.setSource("nupd5182xxsl");
						Integer wz = voteDao.getVoteTjiByType2(vote);

						// 19楼问卷
						vote.setSource("czhi7pjiadhu");
						Integer sjl = voteDao.getVoteTjiByType2(vote);

						// 微博问卷
						vote.setSource("l6e69n6t0xdf");
						Integer wb = voteDao.getVoteTjiByType2(vote);

						// 微博粉丝通问卷
						vote.setSource("osjrem0am5af");
						Integer fs = voteDao.getVoteTjiByType2(vote);

						// 今日头条问卷
						vote.setSource("frvmppoifgmb");
						Integer tt = voteDao.getVoteTjiByType2(vote);

						// 微信公众号问卷
						vote.setSource("43ADF8FC3964");
						Integer gzh = voteDao.getVoteTjiByType2(vote);

						/*
						 * //重复个数 vote.setCfu(0); Integer vote_cf =
						 * voteDao.getVoCountByType(vote);
						 */

						fromUser.setStartTime(sd.parse(list.get(i)).getTime()
								/ 1000 + "");
						fromUser.setEndTime(tommorrow - 1 + "");

						fromUser.setType("");
						zonfrom = fromUserDao.getFromUserStaticByType(fromUser);

						// 专题预约测评
						fromUser.setType("专题预约");
						Integer zt = fromUserDao
								.getFromUserStaticByType2(fromUser);

						// 网站报名
						fromUser.setType("体验课报名");
						Integer wzbm = fromUserDao
								.getFromUserStaticByType2(fromUser);
						// 市场预约
						fromUser.setType("市场部预约");
						Integer e = fromUserDao
								.getFromUserStaticByType2(fromUser);
						if (e != null && e> 0) {
							wzbm +=e;
						}

						fromUser.setType("严马");
						Integer ym = fromUserDao
								.getFromUserStaticByType2(fromUser);

						// 太优网站报名
						fromUser.setType("太优预约");
						Integer ty = fromUserDao
								.getFromUserStaticByType2(fromUser);

						// 免费电话咨询
						fromUser.setType("电话");
						Integer dh = fromUserDao
								.getFromUserStaticByType2(fromUser);

						// app
						fromUser.setType("app");
						Integer app = fromUserDao
								.getFromUserStaticByType2(fromUser);

						// 百度移动网盟
						fromUser.setType("移动网盟");
						Integer bdyd = fromUserDao
								.getFromUserStaticByType2(fromUser);

						/*
						 * fromUser.setCfu(0); Integer from_cf =
						 * fromUserDao.getFromUserCountByType(fromUser);
						 */

						client.setStartTime(list.get(i));
						client.setEndTime(sd.format(DateUtil
								.getTommorrowDay1(sd.parse(list.get(i)))));

						client.setType("");
						zoncilent = clientImpDao
								.getClientImpStatisCByType(client);

						// 离线宝
						client.setType("lixianbao");
						Integer lxb = clientImpDao
								.getClientImpStatisCByType2(client);

						// 今日头条（合作平台）
						client.setType("frvmppoifgmb");
						Integer tt2 = clientImpDao
								.getClientImpStatisCByType2(client);

						// 百度寻客
						client.setType("baiduxunke");
						Integer xk = clientImpDao
								.getClientImpStatisCByType2(client);

						// 商桥留言
						client.setType("edhhjon7t6za");
						Integer sq = clientImpDao
								.getClientImpStatisCByType2(client);

						// 网络推广
						client.setType("8yjy5cw5w5x0");
						Integer wt = clientImpDao
								.getClientImpStatisCByType2(client);

						// 教育联展网
						client.setType("kk51qfgzk1rq");
						Integer jy = clientImpDao
								.getClientImpStatisCByType2(client);

						// 百度糯米
						client.setType("02FAC12A4746");
						Integer bd = clientImpDao
								.getClientImpStatisCByType2(client);

						// 百度信息流
						client.setType("4D189169D77E");
						Integer bdxx = clientImpDao
								.getClientImpStatisCByType2(client);
							
						/*
						 * client.setColor("0"); Integer client_cf =
						 * clientImpDao.getClientListImpCByType(client);
						 */

						if (i == 0) {
							// 取出重复
							Integer zonwjCount = zonwj.size();
							HashMap<String, Integer> hs = new HashMap<String, Integer>();
							for (JsVote v : zonwj) {
								Integer count = 1;
								if (hs.get(v.getPhone()) != null) {
									count = hs.get(v.getPhone()) + 1;
									if (v.getSource().equals("l6xdybjjrcjc")) {
										sj=sj-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("nupd5182xxsl")) {
										wz = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("czhi7pjiadhu")) {
										sjl = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("l6e69n6t0xdf")) {
										wb = wb-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("osjrem0am5af")) {
										fs = fs-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("frvmppoifgmb")) {
										tt = tt-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("43ADF8FC3964")) {
										gzh = gzh-1;
										zonwjCount = zonwjCount-1;
									}
									
								}
								if(v.getPhone() != null){			
									hs.put(v.getPhone(), count);	
								}
									
	
								
							}
							Integer zonfromCount = zonfrom.size();
							for (JsFromUser f : zonfrom) {
								Integer count = 1;
								if (hs.get(f.getPhone()) != null) {
									count = hs.get(f.getPhone()) + 1;
									if (f.getType().indexOf("专题预约")!=-1) {
										zt = zt-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("体验课报名")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("市场部预约")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("严马")!=-1) {
										ym = ym-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("太优预约")!=-1) {
										ty = ty-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("电话")!=-1) {
										dh = dh-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("app")!=-1) {
										app = app-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("移动网盟")!=-1) {
										bdyd = bdyd-1;
										zonfromCount = zonfromCount-1;
									}
									
								}
								if(f.getPhone() != null){
									hs.put(f.getPhone(), count);
								}
								
							}
							Integer zoncilentCount = zoncilent.size();
							for (TgClientImp c : zoncilent) {
								Integer count = 1;
								if (hs.get(c.getPhone()) != null) {
									count = hs.get(c.getPhone()) + 1;
										if (c.getType().equals("lixianbao")) {
											lxb = lxb-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("frvmppoifgmb")){
											tt2 = tt2-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("baiduxunke")){
											xk = xk-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("edhhjon7t6za")){
											sq = sq-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("8yjy5cw5w5x0")){
											wt = wt-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("kk51qfgzk1rq")){
											jy = jy-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("02FAC12A4746")){
											bd = bd-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("4D189169D77E")){
											bdxx = bdxx-1;
											zoncilentCount = zoncilentCount-1;
										}
									
								}
								if(c.getPhone() != null){
									hs.put(c.getPhone(), count);
								}
								
							}

							for (String key : hs.keySet()) {
								if (hs.get(key) != null & hs.get(key) > 1) {
									String cf_phone = key;
									String cf_qudao = "";
									Integer count = 0;

									// 当天
									vote2.setPhone(key);
									vote2.setStartTime(sd.parse(list.get(i))
											.getTime() / 1000);
									vote2.setEndTime(tommorrow);
									List<JsVote> vlist = voteDao
											.getVoteTjiByType(vote2);
									if (vlist != null && vlist.size() > 0) {
										cf_qudao = cf_qudao
												+ vlist.get(0).getSourcens();
										count++;
									}

									fromUser2.setPhone(key);
									fromUser2.setStartTime(sd
											.parse(list.get(i)).getTime()
											/ 1000 + "");
									fromUser2.setEndTime(tommorrow - 1 + "");
									List<JsFromUser> flist = fromUserDao
											.getFromUserStaticByType(fromUser2);
									if (flist != null && flist.size() > 0) {
										if (!cf_qudao.equals("")) {
											cf_qudao = cf_qudao + "和"
													+ flist.get(0).getType();
										} else {
											cf_qudao = cf_qudao
													+ flist.get(0).getType();
										}
										count++;
									}

									client2.setPhone(key);
									client2.setStartTime(list.get(i));
									client2.setEndTime(sd.format(DateUtil
											.getTommorrowDay1(sd.parse(list
													.get(i)))));
									List<TgClientImp> clist = clientImpDao
											.getClientImpStatisCByType(client2);
									if (clist != null && clist.size() > 0) {
										cf_qudao = cf_qudao + "和"
												+ clist.get(0).getSourcens();
										count++;
									}
									slist.add(cf_phone + "," + cf_qudao + ","
											+ count + "," + list.get(i));
								}
							}
							qd0.setTitle("总计");
							qd1.setTitle("手机问卷");
							qd2.setTitle("网站问卷");
							qd3.setTitle("19楼问卷");
							qd4.setTitle("微博问卷");
							qd5.setTitle("微博粉丝通问卷问卷");
							qd6.setTitle("今日头条问卷");
							qd7.setTitle("微信公众号问卷");
							qd8.setTitle("太优问卷");
							qd9.setTitle("专题预约测评");
							qd10.setTitle("网站报名");
							qd11.setTitle("太优网站报名");
							qd12.setTitle("免费电话咨询");
							qd13.setTitle("app注意力测评");
							qd14.setTitle("离线宝");
							qd15.setTitle("百度移动网盟");
							qd16.setTitle("今日头条（合作平台）");
							qd17.setTitle("百度寻客");
							qd18.setTitle("商桥留言");
							qd19.setTitle("网络部推广");
							qd20.setTitle("教育联展网");
							qd21.setTitle("百度糯米团购");
							qd22.setTitle("百度信息流");

							qd0.setCount1(zonwjCount + zonfromCount
									+ zoncilentCount + "");
							qd1.setCount1(sj + "");
							qd2.setCount1(wz + "");
							qd3.setCount1(sjl + "");
							qd4.setCount1(wb + "");
							qd5.setCount1(fs + "");
							qd6.setCount1(tt + "");
							qd7.setCount1(gzh + "");
							qd8.setCount1(zonwjCount - sj - wz
									- sjl - wb - fs
									- tt - gzh + "");
							qd9.setCount1(zt + "");
							qd10.setCount1(wzbm
									+ ym
									+ (zonfromCount - zt - wzbm
											- ym - ty - dh
											- app - bdyd) + "");
							qd11.setCount1(ty + "");
							qd12.setCount1(dh + "");
							qd13.setCount1(app + "");
							qd14.setCount1(lxb + "");
							qd15.setCount1(bdyd + "");
							qd16.setCount1(tt2 + "");
							qd17.setCount1(xk + "");
							qd18.setCount1(sq + "");
							qd19.setCount1(wt + "");
							qd20.setCount1(jy + "");
							qd21.setCount1(bd + "");
							qd22.setCount1(bdxx + "");
						} else if (i == 1) {
							
							// 取出重复
							Integer zonwjCount = zonwj.size();
							HashMap<String, Integer> hs = new HashMap<String, Integer>();
							for (JsVote v : zonwj) {
								Integer count = 1;
								if (hs.get(v.getPhone()) != null) {
									count = hs.get(v.getPhone()) + 1;
									if (v.getSource().equals("l6xdybjjrcjc")) {
										sj=sj-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("nupd5182xxsl")) {
										wz = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("czhi7pjiadhu")) {
										sjl = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("l6e69n6t0xdf")) {
										wb = wb-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("osjrem0am5af")) {
										fs = fs-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("frvmppoifgmb")) {
										tt = tt-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("43ADF8FC3964")) {
										gzh = gzh-1;
										zonwjCount = zonwjCount-1;
									}
									
								}
								if(v.getPhone() != null){
									hs.put(v.getPhone(), count);
								}
								
							}
							Integer zonfromCount = zonfrom.size();
							for (JsFromUser f : zonfrom) {
								Integer count = 1;
								if (hs.get(f.getPhone()) != null) {
									count = hs.get(f.getPhone()) + 1;
									if (f.getType().indexOf("专题预约")!=-1) {
										zt = zt-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("体验课报名")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("市场部预约")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("严马")!=-1) {
										ym = ym-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("太优预约")!=-1) {
										ty = ty-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("电话")!=-1) {
										dh = dh-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("app")!=-1) {
										app = app-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("移动网盟")!=-1) {
										bdyd = bdyd-1;
										zonfromCount = zonfromCount-1;
									}
									
								}
								if(f.getPhone() != null){
									hs.put(f.getPhone(), count);
								}
								
							}
							Integer zoncilentCount = zoncilent.size();
							for (TgClientImp c : zoncilent) {
								Integer count = 1;
								if (hs.get(c.getPhone()) != null) {
									count = hs.get(c.getPhone()) + 1;
										if (c.getType().equals("lixianbao")) {
											lxb = lxb-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("frvmppoifgmb")){
											tt2 = tt2-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("baiduxunke")){
											xk = xk-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("edhhjon7t6za")){
											sq = sq-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("8yjy5cw5w5x0")){
											wt = wt-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("kk51qfgzk1rq")){
											jy = jy-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("02FAC12A4746")){
											bd = bd-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("4D189169D77E")){
											bdxx = bdxx-1;
											zoncilentCount = zoncilentCount-1;
										}
									
								}
								if(c.getPhone() != null){
									hs.put(c.getPhone(), count);

								}
								
							}

							for (String key : hs.keySet()) {
								if (hs.get(key) != null & hs.get(key) > 1) {
									String cf_phone = key;
									String cf_qudao = "";
									Integer count = 0;

									vote2.setPhone(key);
									vote2.setStartTime(sd.parse(list.get(i))
											.getTime() / 1000);
									vote2.setEndTime(tommorrow);
									List<JsVote> vlist = voteDao
											.getVoteTjiByType(vote2);
									if (vlist != null && vlist.size() > 0) {
										cf_qudao = cf_qudao
												+ vlist.get(0).getSourcens();
										count++;
									}

									fromUser2.setPhone(key);
									fromUser2.setStartTime(sd
											.parse(list.get(i)).getTime()
											/ 1000 + "");
									fromUser2.setEndTime(tommorrow - 1 + "");
									List<JsFromUser> flist = fromUserDao
											.getFromUserStaticByType(fromUser2);
									if (flist != null && flist.size() > 0) {
										if (!cf_qudao.equals("")) {
											cf_qudao = cf_qudao + "和"
													+ flist.get(0).getType();
										} else {
											cf_qudao = cf_qudao
													+ flist.get(0).getType();
										}

										count++;
									}

									client2.setPhone(key);
									client2.setStartTime(list.get(i));
									client2.setEndTime(sd.format(DateUtil
											.getTommorrowDay1(sd.parse(list
													.get(i)))));
									List<TgClientImp> clist = clientImpDao
											.getClientImpStatisCByType(client2);
									if (clist != null && clist.size() > 0) {
										cf_qudao = cf_qudao + "和"
												+ clist.get(0).getSourcens();
										count++;
									}
									slist.add(cf_phone + "," + cf_qudao + ","
											+ count + "," + list.get(i));
								}
							}
							qd0.setCount2(zonwjCount + zonfromCount
									+ zoncilentCount + "");
							qd1.setCount2(sj + "");
							qd2.setCount2(wz + "");
							qd3.setCount2(sjl + "");
							qd4.setCount2(wb + "");
							qd5.setCount2(fs + "");
							qd6.setCount2(tt + "");
							qd7.setCount2(gzh + "");
							qd8.setCount2(zonwjCount - sj - wz
									- sjl - wb - fs
									- tt - gzh + "");
							qd9.setCount2(zt + "");
							qd10.setCount2(wzbm + ym + "");
							qd11.setCount2(ty + "");
							qd12.setCount2(dh + "");
							qd13.setCount2(app + "");
							qd14.setCount2(lxb + "");
							qd15.setCount2(bdyd + "");
							qd16.setCount2(tt2 + "");
							qd17.setCount2(xk + "");
							qd18.setCount2(sq + "");
							qd19.setCount2(wt + "");
							qd20.setCount2(jy + "");
							qd21.setCount2(bd + "");
							qd22.setCount2(bdxx + "");
						} else if (i == 2) {
							
							// 取出重复
							Integer zonwjCount = zonwj.size();
							HashMap<String, Integer> hs = new HashMap<String, Integer>();
							for (JsVote v : zonwj) {
								Integer count = 1;
								if (hs.get(v.getPhone()) != null) {
									count = hs.get(v.getPhone()) + 1;
									if (v.getSource().equals("l6xdybjjrcjc")) {
										sj=sj-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("nupd5182xxsl")) {
										wz = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("czhi7pjiadhu")) {
										sjl = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("l6e69n6t0xdf")) {
										wb = wb-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("osjrem0am5af")) {
										fs = fs-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("frvmppoifgmb")) {
										tt = tt-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("43ADF8FC3964")) {
										gzh = gzh-1;
										zonwjCount = zonwjCount-1;
									}
									
								}
								if(v.getPhone() != null){
									hs.put(v.getPhone(), count);	
								}
								
							}
							Integer zonfromCount = zonfrom.size();
							for (JsFromUser f : zonfrom) {
								Integer count = 1;
								if (hs.get(f.getPhone()) != null) {
									count = hs.get(f.getPhone()) + 1;
									if (f.getType().indexOf("专题预约")!=-1) {
										zt = zt-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("体验课报名")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("市场部预约")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("严马")!=-1) {
										ym = ym-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("太优预约")!=-1) {
										ty = ty-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("电话")!=-1) {
										dh = dh-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("app")!=-1) {
										app = app-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("移动网盟")!=-1) {
										bdyd = bdyd-1;
										zonfromCount = zonfromCount-1;
									}
									
								}
								if(f.getPhone() != null){
									hs.put(f.getPhone(), count);
								}
								
							}
							Integer zoncilentCount = zoncilent.size();
							for (TgClientImp c : zoncilent) {
								Integer count = 1;
								if (hs.get(c.getPhone()) != null) {
									count = hs.get(c.getPhone()) + 1;
										if (c.getType().equals("lixianbao")) {
											lxb = lxb-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("frvmppoifgmb")){
											tt2 = tt2-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("baiduxunke")){
											xk = xk-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("edhhjon7t6za")){
											sq = sq-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("8yjy5cw5w5x0")){
											wt = wt-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("kk51qfgzk1rq")){
											jy = jy-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("02FAC12A4746")){
											bd = bd-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("4D189169D77E")){
											bdxx = bdxx-1;
											zoncilentCount = zoncilentCount-1;
										}
									
								}
								if(c.getPhone() != null){
									hs.put(c.getPhone(), count);
								}
								
							}

							for (String key : hs.keySet()) {
								if (hs.get(key) != null & hs.get(key) > 1) {
									String cf_phone = key;
									String cf_qudao = "";
									Integer count = 0;

									vote2.setPhone(key);
									vote2.setStartTime(sd.parse(list.get(i))
											.getTime() / 1000);
									vote2.setEndTime(tommorrow);
									List<JsVote> vlist = voteDao
											.getVoteTjiByType(vote2);
									if (vlist != null && vlist.size() > 0) {
										cf_qudao = cf_qudao
												+ vlist.get(0).getSourcens();
										count++;
									}

									fromUser2.setPhone(key);
									fromUser2.setStartTime(sd
											.parse(list.get(i)).getTime()
											/ 1000 + "");
									fromUser2.setEndTime(tommorrow - 1 + "");
									List<JsFromUser> flist = fromUserDao
											.getFromUserStaticByType(fromUser2);
									if (flist != null && flist.size() > 0) {
										if (!cf_qudao.equals("")) {
											cf_qudao = cf_qudao + "和"
													+ flist.get(0).getType();
										} else {
											cf_qudao = cf_qudao
													+ flist.get(0).getType();
										}

										count++;
									}

									client2.setPhone(key);
									client2.setStartTime(list.get(i));
									client2.setEndTime(sd.format(DateUtil
											.getTommorrowDay1(sd.parse(list
													.get(i)))));
									List<TgClientImp> clist = clientImpDao
											.getClientImpStatisCByType(client2);
									if (clist != null && clist.size() > 0) {
										cf_qudao = cf_qudao + "和"
												+ clist.get(0).getSourcens();
										count++;
									}
									slist.add(cf_phone + "," + cf_qudao + ","
											+ count + "," + list.get(i));
								}
							}
							qd0.setCount3(zonwjCount+ zonfromCount
									+ zoncilentCount + "");
							qd1.setCount3(sj + "");
							qd2.setCount3(wz + "");
							qd3.setCount3(sjl + "");
							qd4.setCount3(wb + "");
							qd5.setCount3(fs + "");
							qd6.setCount3(tt+ "");
							qd7.setCount3(gzh + "");
							qd8.setCount3(zonwjCount- sj - wz
									- sjl - wb- fs
									- tt - gzh + "");
							qd9.setCount3(zt + "");
							qd10.setCount3(wzbm + ym + "");
							qd11.setCount3(ty + "");
							qd12.setCount3(dh + "");
							qd13.setCount3(app + "");
							qd14.setCount3(lxb + "");
							qd15.setCount3(bdyd + "");
							qd16.setCount3(tt2 + "");
							qd17.setCount3(xk + "");
							qd18.setCount3(sq + "");
							qd19.setCount3(wt + "");
							qd20.setCount3(jy + "");
							qd21.setCount3(bd + "");
							qd22.setCount3(bdxx + "");

						} else if (i == 3) {
							
							// 取出重复
							Integer zonwjCount = zonwj.size();
							HashMap<String, Integer> hs = new HashMap<String, Integer>();
							for (JsVote v : zonwj) {
								Integer count = 1;
								if (hs.get(v.getPhone()) != null) {
									count = hs.get(v.getPhone()) + 1;
									if (v.getSource().equals("l6xdybjjrcjc")) {
										sj=sj-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("nupd5182xxsl")) {
										wz = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("czhi7pjiadhu")) {
										sjl = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("l6e69n6t0xdf")) {
										wb = wb-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("osjrem0am5af")) {
										fs = fs-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("frvmppoifgmb")) {
										tt = tt-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("43ADF8FC3964")) {
										gzh = gzh-1;
										zonwjCount = zonwjCount-1;
									}
									
								}
								if(v.getPhone() != null){
									hs.put(v.getPhone(), count);
								}
								
							}
							Integer zonfromCount = zonfrom.size();
							for (JsFromUser f : zonfrom) {
								Integer count = 1;
								if (hs.get(f.getPhone()) != null) {
									count = hs.get(f.getPhone()) + 1;
									if (f.getType().indexOf("专题预约")!=-1) {
										zt = zt-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("体验课报名")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("市场部预约")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("严马")!=-1) {
										ym = ym-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("太优预约")!=-1) {
										ty = ty-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("电话")!=-1) {
										dh = dh-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("app")!=-1) {
										app = app-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("移动网盟")!=-1) {
										bdyd = bdyd-1;
										zonfromCount = zonfromCount-1;
									}
									
								}
								if(f.getPhone() != null){
									hs.put(f.getPhone(), count);
								}
								
							}
							Integer zoncilentCount = zoncilent.size();
							for (TgClientImp c : zoncilent) {
								Integer count = 1;
								if (hs.get(c.getPhone()) != null) {
									count = hs.get(c.getPhone()) + 1;
										if (c.getType().equals("lixianbao")) {
											lxb = lxb-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("frvmppoifgmb")){
											tt2 = tt2-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("baiduxunke")){
											xk = xk-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("edhhjon7t6za")){
											sq = sq-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("8yjy5cw5w5x0")){
											wt = wt-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("kk51qfgzk1rq")){
											jy = jy-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("02FAC12A4746")){
											bd = bd-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("4D189169D77E")){
											bdxx = bdxx-1;
											zoncilentCount = zoncilentCount-1;
										}
									
								}
								if(c.getPhone() != null){
									hs.put(c.getPhone(), count);
								}
								
							}

							for (String key : hs.keySet()) {
								if (hs.get(key) != null & hs.get(key) > 1) {
									String cf_phone = key;
									String cf_qudao = "";
									Integer count = 0;

									vote2.setPhone(key);
									vote2.setStartTime(sd.parse(list.get(i))
											.getTime() / 1000);
									vote2.setEndTime(tommorrow);
									List<JsVote> vlist = voteDao
											.getVoteTjiByType(vote2);
									if (vlist != null && vlist.size() > 0) {
										cf_qudao = cf_qudao
												+ vlist.get(0).getSourcens();
										count++;
									}

									fromUser2.setPhone(key);
									fromUser2.setStartTime(sd
											.parse(list.get(i)).getTime()
											/ 1000 + "");
									fromUser2.setEndTime(tommorrow - 1 + "");
									List<JsFromUser> flist = fromUserDao
											.getFromUserStaticByType(fromUser2);
									if (flist != null && flist.size() > 0) {
										if (!cf_qudao.equals("")) {
											cf_qudao = cf_qudao + "和"
													+ flist.get(0).getType();
										} else {
											cf_qudao = cf_qudao
													+ flist.get(0).getType();
										}

										count++;
									}

									client2.setPhone(key);
									client2.setStartTime(list.get(i));
									client2.setEndTime(sd.format(DateUtil
											.getTommorrowDay1(sd.parse(list
													.get(i)))));
									List<TgClientImp> clist = clientImpDao
											.getClientImpStatisCByType(client2);
									if (clist != null && clist.size() > 0) {
										cf_qudao = cf_qudao + "和"
												+ clist.get(0).getSourcens();
										count++;
									}
									slist.add(cf_phone + "," + cf_qudao + ","
											+ count + "," + list.get(i));
								}
							}
							qd0.setCount4(zonwjCount + zonfromCount
									+ zoncilentCount + "");
							qd1.setCount4(sj  + "");
							qd2.setCount4(wz  + "");
							qd3.setCount4(sjl  + "");
							qd4.setCount4(wb  + "");
							qd5.setCount4(fs  + "");
							qd6.setCount4(tt  + "");
							qd7.setCount4(gzh  + "");
							qd8.setCount4(zonwjCount - sj - wz
									- sjl- wb - fs
									- tt- gzh + "");
							qd9.setCount4(zt + "");
							qd10.setCount4(wzbm + ym + "");
							qd11.setCount4(ty + "");
							qd12.setCount4(dh + "");
							qd13.setCount4(app + "");
							qd14.setCount4(lxb + "");
							qd15.setCount4(bdyd + "");
							qd16.setCount4(tt2 + "");
							qd17.setCount4(xk + "");
							qd18.setCount4(sq + "");
							qd19.setCount4(wt + "");
							qd20.setCount4(jy + "");
							qd21.setCount4(bd + "");
							qd22.setCount4(bdxx + "");

						} else if (i == 4) {
							// 取出重复
							Integer zonwjCount = zonwj.size();
							HashMap<String, Integer> hs = new HashMap<String, Integer>();
							for (JsVote v : zonwj) {
								Integer count = 1;
								if (hs.get(v.getPhone()) != null) {
									count = hs.get(v.getPhone()) + 1;
									if (v.getSource().equals("l6xdybjjrcjc")) {
										sj=sj-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("nupd5182xxsl")) {
										wz = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("czhi7pjiadhu")) {
										sjl = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("l6e69n6t0xdf")) {
										wb = wb-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("osjrem0am5af")) {
										fs = fs-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("frvmppoifgmb")) {
										tt = tt-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("43ADF8FC3964")) {
										gzh = gzh-1;
										zonwjCount = zonwjCount-1;
									}
									
								}
								if(v.getPhone() != null){
									hs.put(v.getPhone(), count);
								}
							
							}
							Integer zonfromCount = zonfrom.size();
							for (JsFromUser f : zonfrom) {
								Integer count = 1;
								if (hs.get(f.getPhone()) != null) {
									count = hs.get(f.getPhone()) + 1;
									if (f.getType().indexOf("专题预约")!=-1) {
										zt = zt-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("体验课报名")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("市场部预约")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("严马")!=-1) {
										ym = ym-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("太优预约")!=-1) {
										ty = ty-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("电话")!=-1) {
										dh = dh-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("app")!=-1) {
										app = app-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("移动网盟")!=-1) {
										bdyd = bdyd-1;
										zonfromCount = zonfromCount-1;
									}
									
								}
								if(f.getPhone() != null){
									hs.put(f.getPhone(), count);
								}
								
							}
							Integer zoncilentCount = zoncilent.size();
							for (TgClientImp c : zoncilent) {
								Integer count = 1;
								if (hs.get(c.getPhone()) != null) {
									count = hs.get(c.getPhone()) + 1;
										if (c.getType().equals("lixianbao")) {
											lxb = lxb-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("frvmppoifgmb")){
											tt2 = tt2-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("baiduxunke")){
											xk = xk-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("edhhjon7t6za")){
											sq = sq-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("8yjy5cw5w5x0")){
											wt = wt-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("kk51qfgzk1rq")){
											jy = jy-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("02FAC12A4746")){
											bd = bd-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("4D189169D77E")){
											bdxx = bdxx-1;
											zoncilentCount = zoncilentCount-1;
										}
									
								}
								if(c.getPhone() != null){
									hs.put(c.getPhone(), count);
								}
							
							}

							for (String key : hs.keySet()) {
								if (hs.get(key) != null & hs.get(key) > 1) {
									String cf_phone = key;
									String cf_qudao = "";
									Integer count = 0;

									vote2.setPhone(key);
									vote2.setStartTime(sd.parse(list.get(i))
											.getTime() / 1000);
									vote2.setEndTime(tommorrow);
									List<JsVote> vlist = voteDao
											.getVoteTjiByType(vote2);
									if (vlist != null && vlist.size() > 0) {
										cf_qudao = cf_qudao
												+ vlist.get(0).getSourcens();
										count++;
									}

									fromUser2.setPhone(key);
									fromUser2.setStartTime(sd
											.parse(list.get(i)).getTime()
											/ 1000 + "");
									fromUser2.setEndTime(tommorrow - 1 + "");
									List<JsFromUser> flist = fromUserDao
											.getFromUserStaticByType(fromUser2);
									if (flist != null && flist.size() > 0) {
										if (!cf_qudao.equals("")) {
											cf_qudao = cf_qudao + "和"
													+ flist.get(0).getType();
										} else {
											cf_qudao = cf_qudao
													+ flist.get(0).getType();
										}

										count++;
									}

									client2.setPhone(key);
									client2.setStartTime(list.get(i));
									client2.setEndTime(sd.format(DateUtil
											.getTommorrowDay1(sd.parse(list
													.get(i)))));
									List<TgClientImp> clist = clientImpDao
											.getClientImpStatisCByType(client2);
									if (clist != null && clist.size() > 0) {
										cf_qudao = cf_qudao + "和"
												+ clist.get(0).getSourcens();
										count++;
									}
									slist.add(cf_phone + "," + cf_qudao + ","
											+ count + "," + list.get(i));
								}
							}
							qd0.setCount5(zonwjCount+ zonfromCount
									+ zoncilentCount+ "");
							qd1.setCount5(sj + "");
							qd2.setCount5(wz + "");
							qd3.setCount5(sjl + "");
							qd4.setCount5(wb + "");
							qd5.setCount5(fs + "");
							qd6.setCount5(tt + "");
							qd7.setCount5(gzh + "");
							qd8.setCount5(zonwjCount - sj - wz
									- sjl - wb - fs
									- tt - gzh + "");
							qd9.setCount5(zt + "");
							qd10.setCount5(wzbm + ym + "");
							qd11.setCount5(ty + "");
							qd12.setCount5(dh + "");
							qd13.setCount5(app + "");
							qd14.setCount5(lxb + "");
							qd15.setCount5(bdyd + "");
							qd16.setCount5(tt2 + "");
							qd17.setCount5(xk + "");
							qd18.setCount5(sq + "");
							qd19.setCount5(wt + "");
							qd20.setCount5(jy + "");
							qd21.setCount5(bd + "");
							qd22.setCount5(bdxx + "");

						} else if (i == 5) {
							
							// 取出重复
							Integer zonwjCount = zonwj.size();
							HashMap<String, Integer> hs = new HashMap<String, Integer>();
							for (JsVote v : zonwj) {
								Integer count = 1;
								if (hs.get(v.getPhone()) != null) {
									count = hs.get(v.getPhone()) + 1;
									if (v.getSource().equals("l6xdybjjrcjc")) {
										sj=sj-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("nupd5182xxsl")) {
										wz = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("czhi7pjiadhu")) {
										sjl = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("l6e69n6t0xdf")) {
										wb = wb-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("osjrem0am5af")) {
										fs = fs-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("frvmppoifgmb")) {
										tt = tt-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("43ADF8FC3964")) {
										gzh = gzh-1;
										zonwjCount = zonwjCount-1;
									}
									
								}
								if(v.getPhone() != null){
									hs.put(v.getPhone(), count);
								}
								
							}
							Integer zonfromCount = zonfrom.size();
							for (JsFromUser f : zonfrom) {
								Integer count = 1;
								if (hs.get(f.getPhone()) != null) {
									count = hs.get(f.getPhone()) + 1;
									if (f.getType().indexOf("专题预约")!=-1) {
										zt = zt-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("体验课报名")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("市场部预约")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("严马")!=-1) {
										ym = ym-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("太优预约")!=-1) {
										ty = ty-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("电话")!=-1) {
										dh = dh-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("app")!=-1) {
										app = app-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("移动网盟")!=-1) {
										bdyd = bdyd-1;
										zonfromCount = zonfromCount-1;
									}
									
								}
								if(f.getPhone() != null){
									hs.put(f.getPhone(), count);
								}
								
							}
							Integer zoncilentCount = zoncilent.size();
							for (TgClientImp c : zoncilent) {
								Integer count = 1;
								if (hs.get(c.getPhone()) != null) {
									count = hs.get(c.getPhone()) + 1;
										if (c.getType().equals("lixianbao")) {
											lxb = lxb-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("frvmppoifgmb")){
											tt2 = tt2-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("baiduxunke")){
											xk = xk-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("edhhjon7t6za")){
											sq = sq-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("8yjy5cw5w5x0")){
											wt = wt-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("kk51qfgzk1rq")){
											jy = jy-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("02FAC12A4746")){
											bd = bd-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("4D189169D77E")){
											bdxx = bdxx-1;
											zoncilentCount = zoncilentCount-1;
										}
									
								}
								if(c.getPhone() != null){
									hs.put(c.getPhone(), count);
								}
								
							}

							for (String key : hs.keySet()) {
								if (hs.get(key) != null & hs.get(key) > 1) {
									String cf_phone = key;
									String cf_qudao = "";
									Integer count = 0;

									vote2.setPhone(key);
									vote2.setStartTime(sd.parse(list.get(i))
											.getTime() / 1000);
									vote2.setEndTime(tommorrow);
									List<JsVote> vlist = voteDao
											.getVoteTjiByType(vote2);
									if (vlist != null && vlist.size() > 0) {
										cf_qudao = cf_qudao
												+ vlist.get(0).getSourcens();
										count++;
									}

									fromUser2.setPhone(key);
									fromUser2.setStartTime(sd
											.parse(list.get(i)).getTime()
											/ 1000 + "");
									fromUser2.setEndTime(tommorrow - 1 + "");
									List<JsFromUser> flist = fromUserDao
											.getFromUserStaticByType(fromUser2);
									if (flist != null && flist.size() > 0) {
										if (!cf_qudao.equals("")) {
											cf_qudao = cf_qudao + "和"
													+ flist.get(0).getType();
										} else {
											cf_qudao = cf_qudao
													+ flist.get(0).getType();
										}

										count++;
									}

									client2.setPhone(key);
									client2.setStartTime(list.get(i));
									client2.setEndTime(sd.format(DateUtil
											.getTommorrowDay1(sd.parse(list
													.get(i)))));
									List<TgClientImp> clist = clientImpDao
											.getClientImpStatisCByType(client2);
									if (clist != null && clist.size() > 0) {
										cf_qudao = cf_qudao + "和"
												+ clist.get(0).getSourcens();
										count++;
									}
									slist.add(cf_phone + "," + cf_qudao + ","
											+ count + "," + list.get(i));
								}
							}
							qd0.setCount6(zonwjCount + zonfromCount
									+ zoncilentCount + "");
							qd1.setCount6(sj + "");
							qd2.setCount6(wz + "");
							qd3.setCount6(sjl + "");
							qd4.setCount6(wb + "");
							qd5.setCount6(fs + "");
							qd6.setCount6(tt + "");
							qd7.setCount6(gzh + "");
							qd8.setCount6(zonwjCount - sj - wz
									- sjl - wb - fs
									- tt - gzh + "");
							qd9.setCount6(zt + "");
							qd10.setCount6(wzbm + ym + "");
							qd11.setCount6(ty + "");
							qd12.setCount6(dh + "");
							qd13.setCount6(app + "");
							qd14.setCount6(lxb + "");
							qd15.setCount6(bdyd + "");
							qd16.setCount6(tt2 + "");
							qd17.setCount6(xk + "");
							qd18.setCount6(sq + "");
							qd19.setCount6(wt + "");
							qd20.setCount6(jy + "");
							qd21.setCount6(bd + "");
							qd22.setCount6(bdxx + "");
						} else if (i == 6) {
							
							// 取出重复
							Integer zonwjCount = zonwj.size();
							HashMap<String, Integer> hs = new HashMap<String, Integer>();
							for (JsVote v : zonwj) {
								Integer count = 1;
								if (hs.get(v.getPhone()) != null) {
									count = hs.get(v.getPhone()) + 1;
									if (v.getSource().equals("l6xdybjjrcjc")) {
										sj=sj-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("nupd5182xxsl")) {
										wz = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("czhi7pjiadhu")) {
										sjl = wz-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("l6e69n6t0xdf")) {
										wb = wb-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("osjrem0am5af")) {
										fs = fs-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("frvmppoifgmb")) {
										tt = tt-1;
										zonwjCount = zonwjCount-1;
									}else if (v.getSource().equals("43ADF8FC3964")) {
										gzh = gzh-1;
										zonwjCount = zonwjCount-1;
									}
									
								}
								if(v.getPhone() != null){
									hs.put(v.getPhone(), count);
								}
								
							}
							Integer zonfromCount = zonfrom.size();
							for (JsFromUser f : zonfrom) {
								Integer count = 1;
								if (hs.get(f.getPhone()) != null) {
									count = hs.get(f.getPhone()) + 1;
									if (f.getType().indexOf("专题预约")!=-1) {
										zt = zt-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("体验课报名")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("市场部预约")!=-1) {
										wzbm = wzbm-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("严马")!=-1) {
										ym = ym-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("太优预约")!=-1) {
										ty = ty-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("电话")!=-1) {
										dh = dh-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("app")!=-1) {
										app = app-1;
										zonfromCount = zonfromCount-1;
									}else if (f.getType().indexOf("移动网盟")!=-1) {
										bdyd = bdyd-1;
										zonfromCount = zonfromCount-1;
									}
									
								}
								if(f.getPhone() != null){
									hs.put(f.getPhone(), count);
								}
								
							}
							Integer zoncilentCount = zoncilent.size();
							for (TgClientImp c : zoncilent) {
								Integer count = 1;
								if (hs.get(c.getPhone()) != null) {
									count = hs.get(c.getPhone()) + 1;
										if (c.getType().equals("lixianbao")) {
											lxb = lxb-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("frvmppoifgmb")){
											tt2 = tt2-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("baiduxunke")){
											xk = xk-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("edhhjon7t6za")){
											sq = sq-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("8yjy5cw5w5x0")){
											wt = wt-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("kk51qfgzk1rq")){
											jy = jy-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("02FAC12A4746")){
											bd = bd-1;
											zoncilentCount = zoncilentCount-1;
										}else if(c.getType().equals("4D189169D77E")){
											bdxx = bdxx-1;
											zoncilentCount = zoncilentCount-1;
										}
									
								}
								if(c.getPhone() != null){
									hs.put(c.getPhone(), count);
								}
							
							}

							for (String key : hs.keySet()) {
								if (hs.get(key) != null & hs.get(key) > 1) {
									String cf_phone = key;
									String cf_qudao = "";
									Integer count = 0;

									vote2.setPhone(key);
									vote2.setStartTime(sd.parse(list.get(i))
											.getTime() / 1000);
									vote2.setEndTime(tommorrow);
									List<JsVote> vlist = voteDao
											.getVoteTjiByType(vote2);
									if (vlist != null && vlist.size() > 0) {
										cf_qudao = cf_qudao
												+ vlist.get(0).getSourcens();
										count++;
									}

									fromUser2.setPhone(key);
									fromUser2.setStartTime(sd
											.parse(list.get(i)).getTime()
											/ 1000 + "");
									fromUser2.setEndTime(tommorrow - 1 + "");
									List<JsFromUser> flist = fromUserDao
											.getFromUserStaticByType(fromUser2);
									if (flist != null && flist.size() > 0) {
										if (!cf_qudao.equals("")) {
											cf_qudao = cf_qudao + "和"
													+ flist.get(0).getType();
										} else {
											cf_qudao = cf_qudao
													+ flist.get(0).getType();
										}

										count++;
									}

									client2.setPhone(key);
									client2.setStartTime(list.get(i));
									client2.setEndTime(sd.format(DateUtil
											.getTommorrowDay1(sd.parse(list
													.get(i)))));
									List<TgClientImp> clist = clientImpDao
											.getClientImpStatisCByType(client2);
									if (clist != null && clist.size() > 0) {
										cf_qudao = cf_qudao + "和"
												+ clist.get(0).getSourcens();
										count++;
									}
									slist.add(cf_phone + "," + cf_qudao + ","
											+ count + "," + list.get(i));
								}
							}qd0.setCount7(zonwjCount + zonfromCount
									+ zoncilentCount + "");
							qd1.setCount7(sj + "");
							qd2.setCount7(wz + "");
							qd3.setCount7(sjl + "");
							qd4.setCount7(wb + "");
							qd5.setCount7(fs + "");
							qd6.setCount7(tt + "");
							qd7.setCount7(gzh + "");
							qd8.setCount7(zonwjCount - sj - wz
									- sjl - wb - fs
									- tt - gzh + "");
							qd9.setCount7(zt + "");
							qd10.setCount7(wzbm + ym + "");
							qd11.setCount7(ty + "");
							qd12.setCount7(dh + "");
							qd13.setCount7(app + "");
							qd14.setCount7(lxb + "");
							qd15.setCount7(bdyd + "");
							qd16.setCount7(tt2 + "");
							qd17.setCount7(xk + "");
							qd18.setCount7(sq + "");
							qd19.setCount7(wt + "");
							qd20.setCount7(jy + "");
							qd21.setCount7(bd + "");
							qd22.setCount7(bdxx + "");

						}

					}
					qdList.add(qd0);
					qdList.add(qd1);
					qdList.add(qd2);
					qdList.add(qd3);
					qdList.add(qd4);
					qdList.add(qd5);
					qdList.add(qd6);
					qdList.add(qd7);
					qdList.add(qd8);
					qdList.add(qd9);
					qdList.add(qd10);
					qdList.add(qd11);
					qdList.add(qd12);
					qdList.add(qd13);
					qdList.add(qd14);
					qdList.add(qd15);
					qdList.add(qd16);
					qdList.add(qd17);
					qdList.add(qd18);
					qdList.add(qd19);
					qdList.add(qd20);
					qdList.add(qd21);
					qdList.add(qd22);
					result.setDefaultModel("time", time);
					result.setDefaultModel("list", list);
					result.setDefaultModel("qdList", qdList);
					result.setDefaultModel("slist", slist);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("system/statis/system_qudao_statis2", modelMap);
	}

	// 来源渠道数量统计
	@RequestMapping(value = "/system_channel_statis")
	public ModelAndView system_channel_statis(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String time = request.getParameter("time");
					String type = request.getParameter("type");

					SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

					if (time == null || "".equals(time)) {
						time = sd.format(new Date());
					}
					if (type == null || "".equals(type)) {
						type = "1";
					}
					result.setDefaultModel("time", time);
					result.setDefaultModel("type", type);
					List<String> datelist = DateUtil.getdatebymonth(time);
					if (datelist != null && datelist.size() > 0) {
						/* 网推入口 */
						List<String> tglist = new ArrayList<String>();// 推广问卷
						List<String> sqlist = new ArrayList<String>();// 商桥
						List<String> sblist = new ArrayList<String>();// 400转分机
						List<String> bmlist = new ArrayList<String>();// 网站报名
						List<String> qqlist = new ArrayList<String>();// qq老资料
						List<String> gjlist = new ArrayList<String>();// 赶集网
						List<String> wblist = new ArrayList<String>();// 58同城
						List<String> jylist = new ArrayList<String>();// 教育联展网
						List<String> yxlist = new ArrayList<String>();// 云销客

						/* 机构合作 */
						List<String> hhlist = new ArrayList<String>();// 哈哈儿童
						List<String> pxlist = new ArrayList<String>();// 培训通
						List<String> fxlist = new ArrayList<String>();// 返学费
						List<String> sxlist = new ArrayList<String>();// 搜学校
						List<String> sjlist = new ArrayList<String>();// 19楼

						/* 竞价入口 */
						List<String> wzwjlist = new ArrayList<String>();// 网站问卷
						List<String> sjwjlist = new ArrayList<String>();// 手机问卷
						List<String> wzbmlist = new ArrayList<String>();// 网站报名
						List<String> bdlist = new ArrayList<String>();// 百度产品
						List<String> ttlist = new ArrayList<String>();// 今日头条

						/* 市场入口 */
						List<String> gylist = new ArrayList<String>();// 公益讲座
						List<String> cdlist = new ArrayList<String>();// 传单派发
						List<String> sclist = new ArrayList<String>();// 市场推广

						/* 文创入口 */
						List<String> wbolist = new ArrayList<String>();// 微博
						List<String> ttlist2 = new ArrayList<String>();// 今日头条
						List<String> wxlist = new ArrayList<String>();// 微信问卷

						for (int i = 0; i < datelist.size(); i++) {
							if (datelist.get(i) != null
									&& !"".equals(datelist.get(i))) {
								String startTime = datelist.get(i);
								String endTime = sdf.format(DateUtil
										.getTommorrowDay1(sdf.parse(startTime)));

								if (type.equals("1")) {// 网推入口
									TgClientImp clientImp1 = new TgClientImp();
									clientImp1.setStartTime(startTime);
									clientImp1.setEndTime(endTime);
									clientImp1.setType("wtukdq8gp65h");// 推广问卷--市场部问卷
									List<TgClientImp> clientImpList1 = clientImpDao
											.getClientImpByType(clientImp1);
									tglist.add(clientImpList1.size() + "");

									TgClientImp clientImp2 = new TgClientImp();
									clientImp2.setStartTime(startTime);
									clientImp2.setEndTime(endTime);
									clientImp2.setType("edhhjon7t6za");// 商桥--商桥留言
									List<TgClientImp> clientImpList2 = clientImpDao
											.getClientImpByType(clientImp2);
									TgClientImp clientImp3 = new TgClientImp();
									clientImp3.setStartTime(startTime);
									clientImp3.setEndTime(endTime);
									clientImp3.setType("pmvk5vdc6ity");// 商桥--商桥其他
									List<TgClientImp> clientImpList3 = clientImpDao
											.getClientImpByType(clientImp3);
									sqlist.add(clientImpList2.size()
											+ clientImpList3.size() + "");

									TgClientImp clientImp4 = new TgClientImp();
									clientImp4.setStartTime(startTime);
									clientImp4.setEndTime(endTime);
									clientImp4.setType("wtukdq8gp65h");// 400转分机--400电话
									List<TgClientImp> clientImpList4 = clientImpDao
											.getClientImpByType(clientImp4);
									sblist.add(clientImpList4.size() + "");

									TgClientImp clientImp5 = new TgClientImp();
									clientImp5.setStartTime(startTime);
									clientImp5.setEndTime(endTime);
									clientImp5.setType("13b6lzltt0xk");// 网站报名
									List<TgClientImp> clientImpList5 = clientImpDao
											.getClientImpByType(clientImp5);
									bmlist.add(clientImpList5.size() + "");

									TgClientImp clientImp6 = new TgClientImp();
									clientImp6.setStartTime(startTime);
									clientImp6.setEndTime(endTime);
									clientImp6.setType("k3i6bvxdlm2d");// QQ来源--QQ老资料
									List<TgClientImp> clientImpList6 = clientImpDao
											.getClientImpByType(clientImp6);
									qqlist.add(clientImpList6.size() + "");

									TgClientImp clientImp7 = new TgClientImp();
									clientImp7.setStartTime(startTime);
									clientImp7.setEndTime(endTime);
									clientImp7.setType("cxn6ozuszles");// 赶集网
									List<TgClientImp> clientImpList7 = clientImpDao
											.getClientImpByType(clientImp7);
									gjlist.add(clientImpList7.size() + "");

									TgClientImp clientImp8 = new TgClientImp();
									clientImp8.setStartTime(startTime);
									clientImp8.setEndTime(endTime);
									clientImp8.setType("96tcllg3xk21");// 58同城
									List<TgClientImp> clientImpList8 = clientImpDao
											.getClientImpByType(clientImp8);
									wblist.add(clientImpList8.size() + "");

									TgClientImp clientImp9 = new TgClientImp();
									clientImp9.setStartTime(startTime);
									clientImp9.setEndTime(endTime);
									clientImp9.setType("kk51qfgzk1rq");// 教育联展网
									List<TgClientImp> clientImpList9 = clientImpDao
											.getClientImpByType(clientImp9);
									jylist.add(clientImpList9.size() + "");

									TgClientImp clientImp10 = new TgClientImp();
									clientImp10.setStartTime(startTime);
									clientImp10.setEndTime(endTime);
									clientImp10.setType("yunxiaoke");// 云销客
									List<TgClientImp> clientImpList10 = clientImpDao
											.getClientImpByType(clientImp10);
									yxlist.add(clientImpList10.size() + "");
								} else if (type.equals("2")) {// 机构合作
									TgClientImp clientImp1 = new TgClientImp();
									clientImp1.setStartTime(startTime);
									clientImp1.setEndTime(endTime);
									clientImp1.setType("oaw3mfz6l521");// 哈哈儿童网
									List<TgClientImp> clientImpList1 = clientImpDao
											.getClientImpByType(clientImp1);
									hhlist.add(clientImpList1.size() + "");

									TgClientImp clientImp2 = new TgClientImp();
									clientImp2.setStartTime(startTime);
									clientImp2.setEndTime(endTime);
									clientImp2.setType("nmeq3ambzitw");// 培训通
									List<TgClientImp> clientImpList2 = clientImpDao
											.getClientImpByType(clientImp2);
									pxlist.add(clientImpList2.size() + "");

									TgClientImp clientImp3 = new TgClientImp();
									clientImp3.setStartTime(startTime);
									clientImp3.setEndTime(endTime);
									clientImp3.setType("txrf7rjlaq0n");// 返学费网
									List<TgClientImp> clientImpList3 = clientImpDao
											.getClientImpByType(clientImp3);
									fxlist.add(clientImpList3.size() + "");

									TgClientImp clientImp4 = new TgClientImp();
									clientImp4.setStartTime(startTime);
									clientImp4.setEndTime(endTime);
									clientImp4.setType("3uz0gyx626dp");// 搜学校网
									List<TgClientImp> clientImpList4 = clientImpDao
											.getClientImpByType(clientImp4);
									sxlist.add(clientImpList4.size() + "");

									TgClientImp clientImp5 = new TgClientImp();
									clientImp5.setStartTime(startTime);
									clientImp5.setEndTime(endTime);
									clientImp5.setType("czhi7pjiadhu");// 19楼问卷
									List<TgClientImp> clientImpList5 = clientImpDao
											.getClientImpByType(clientImp5);
									sjlist.add(clientImpList5.size() + "");
								} else if (type.equals("3")) {// 竞价入口
									TgClientImp clientImp1 = new TgClientImp();
									clientImp1.setStartTime(startTime);
									clientImp1.setEndTime(endTime);
									clientImp1.setType("nupd5182xxsl");// 网站问卷
									List<TgClientImp> clientImpList1 = clientImpDao
											.getClientImpByType(clientImp1);
									wzwjlist.add(clientImpList1.size() + "");

									TgClientImp clientImp2 = new TgClientImp();
									clientImp2.setStartTime(startTime);
									clientImp2.setEndTime(endTime);
									clientImp2.setType("l6xdybjjrcjc");// 手机问卷
									List<TgClientImp> clientImpList2 = clientImpDao
											.getClientImpByType(clientImp2);
									sjwjlist.add(clientImpList2.size() + "");

									TgClientImp clientImp3 = new TgClientImp();
									clientImp3.setStartTime(startTime);
									clientImp3.setEndTime(endTime);
									clientImp3.setType("13b6lzltt0xk");// 网站报名
									List<TgClientImp> clientImpList3 = clientImpDao
											.getClientImpByType(clientImp3);
									wzbmlist.add(clientImpList3.size() + "");

									TgClientImp clientImp4 = new TgClientImp();
									clientImp4.setStartTime(startTime);
									clientImp4.setEndTime(endTime);
									clientImp4.setType("jd2q59wq41ed");// 百度产品--百度搜索
									List<TgClientImp> clientImpList4 = clientImpDao
											.getClientImpByType(clientImp4);
									TgClientImp clientImp5 = new TgClientImp();
									clientImp5.setStartTime(startTime);
									clientImp5.setEndTime(endTime);
									clientImp5.setType("l0j9fitg3t94");// 百度产品--百度自然搜索
									List<TgClientImp> clientImpList5 = clientImpDao
											.getClientImpByType(clientImp5);
									TgClientImp clientImp6 = new TgClientImp();
									clientImp6.setStartTime(startTime);
									clientImp6.setEndTime(endTime);
									clientImp6.setType("cwo3dhreyo3g");// 百度产品--百度知道
									List<TgClientImp> clientImpList6 = clientImpDao
											.getClientImpByType(clientImp6);
									TgClientImp clientImp7 = new TgClientImp();
									clientImp7.setStartTime(startTime);
									clientImp7.setEndTime(endTime);
									clientImp7.setType("hcat5zqt7jta");// 百度产品--百度教育
									List<TgClientImp> clientImpList7 = clientImpDao
											.getClientImpByType(clientImp7);
									TgClientImp clientImp8 = new TgClientImp();
									clientImp8.setStartTime(startTime);
									clientImp8.setEndTime(endTime);
									clientImp8.setType("251mokab1mtn");// 百度产品--百度网盟
									List<TgClientImp> clientImpList8 = clientImpDao
											.getClientImpByType(clientImp8);
									bdlist.add(clientImpList4.size()
											+ clientImpList5.size()
											+ clientImpList6.size()
											+ clientImpList7.size()
											+ clientImpList8.size() + "");

									TgClientImp clientImp9 = new TgClientImp();
									clientImp9.setStartTime(startTime);
									clientImp9.setEndTime(endTime);
									clientImp9.setType("frvmppoifgmb");// 今日头条
									List<TgClientImp> clientImpList9 = clientImpDao
											.getClientImpByType(clientImp9);
									ttlist.add(clientImpList9.size() + "");
								} else if (type.equals("4")) {// 市场入口
									TgClientImp clientImp1 = new TgClientImp();
									clientImp1.setStartTime(startTime);
									clientImp1.setEndTime(endTime);
									clientImp1.setType("3p5idbdw49di");// 公益讲座
									List<TgClientImp> clientImpList1 = clientImpDao
											.getClientImpByType(clientImp1);
									gylist.add(clientImpList1.size() + "");

									TgClientImp clientImp2 = new TgClientImp();
									clientImp2.setStartTime(startTime);
									clientImp2.setEndTime(endTime);
									clientImp2.setType("gx50j0s9hrr1");// 传单派发
									List<TgClientImp> clientImpList2 = clientImpDao
											.getClientImpByType(clientImp2);
									cdlist.add(clientImpList2.size() + "");

									TgClientImp clientImp3 = new TgClientImp();
									clientImp3.setStartTime(startTime);
									clientImp3.setEndTime(endTime);
									clientImp3.setType("ct5yq4jhc6c7");// 市场推广
									List<TgClientImp> clientImpList3 = clientImpDao
											.getClientImpByType(clientImp3);
									sclist.add(clientImpList3.size() + "");
								} else if (type.equals("5")) {// 文创入口
									TgClientImp clientImp1 = new TgClientImp();
									clientImp1.setStartTime(startTime);
									clientImp1.setEndTime(endTime);
									clientImp1.setType("l6e69n6t0xdf");// 微博问卷
									List<TgClientImp> clientImpList1 = clientImpDao
											.getClientImpByType(clientImp1);
									TgClientImp clientImp2 = new TgClientImp();
									clientImp2.setStartTime(startTime);
									clientImp2.setEndTime(endTime);
									clientImp2.setType("osjrem0am5af");// 微博粉丝通问卷
									List<TgClientImp> clientImpList2 = clientImpDao
											.getClientImpByType(clientImp2);
									wbolist.add(clientImpList1.size()
											+ clientImpList2.size() + "");

									TgClientImp clientImp3 = new TgClientImp();
									clientImp3.setStartTime(startTime);
									clientImp3.setEndTime(endTime);
									clientImp3.setType("frvmppoifgmb");// 今日头条
									List<TgClientImp> clientImpList3 = clientImpDao
											.getClientImpByType(clientImp3);
									ttlist2.add(clientImpList3.size() + "");

									TgClientImp clientImp4 = new TgClientImp();
									clientImp4.setStartTime(startTime);
									clientImp4.setEndTime(endTime);
									clientImp4.setType("ro9iszkillrp");// 微信问卷
									List<TgClientImp> clientImpList4 = clientImpDao
											.getClientImpByType(clientImp4);
									wxlist.add(clientImpList4.size() + "");
								}

							}
						}
						result.setDefaultModel("tglist", tglist);
						result.setDefaultModel("sqlist", sqlist);
						result.setDefaultModel("sblist", sblist);
						result.setDefaultModel("bmlist", bmlist);
						result.setDefaultModel("qqlist", qqlist);
						result.setDefaultModel("gjlist", gjlist);
						result.setDefaultModel("wblist", wblist);
						result.setDefaultModel("jylist", jylist);
						result.setDefaultModel("yxlist", yxlist);

						result.setDefaultModel("hhlist", hhlist);
						result.setDefaultModel("pxlist", pxlist);
						result.setDefaultModel("fxlist", fxlist);
						result.setDefaultModel("sxlist", sxlist);
						result.setDefaultModel("sjlist", sjlist);

						result.setDefaultModel("wzwjlist", wzwjlist);
						result.setDefaultModel("sjwjlist", sjwjlist);
						result.setDefaultModel("wzbmlist", wzbmlist);
						result.setDefaultModel("bdlist", bdlist);
						result.setDefaultModel("ttlist", ttlist);

						result.setDefaultModel("gylist", gylist);
						result.setDefaultModel("cdlist", cdlist);
						result.setDefaultModel("sclist", sclist);

						result.setDefaultModel("wbolist", wbolist);
						result.setDefaultModel("ttlist2", ttlist2);
						result.setDefaultModel("wxlist", wxlist);
					}
					result.setDefaultModel("datelist", datelist);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("system/statis/system_channel_statis", modelMap);
	}

	// 问卷数量统计
	@RequestMapping(value = "/system_wenjuan_statis")
	public ModelAndView system_ctwenjuan_statis(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String time = request.getParameter("time");

					SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

					if (time == null || "".equals(time)) {
						time = sd.format(new Date());
					}
					result.setDefaultModel("time", time);

					List<String> list = Constants.cityMap;
					List<CityWenjuan> wjList = new ArrayList<CityWenjuan>();
					for (int i = 0; i < list.size(); i++) {
						CityWenjuan cityWenjuan = new CityWenjuan();
						cityWenjuan.setCity(list.get(i));
						wjList.add(cityWenjuan);
					}
					if (wjList != null && wjList.size() > 0) {
						for (CityWenjuan wj : wjList) {
							List<String> datelist = DateUtil
									.getdatebymonth(time);
							if (datelist != null && datelist.size() > 0) {
								String date = "";
								String zwjCount = "";
								String ddzxCount = "";
								String bjCount = "";
								String shCount = "";
								String szCount = "";
								String hzCount = "";
								String njCount = "";
								String tjCount = "";
								String gzCount = "";
								String suzCount = "";
								String nbCount = "";
								String wxCount = "";
								String whCount = "";
								String csCount = "";
								String cqCount = "";
								String cdCount = "";
								for (int i = 0; i < datelist.size(); i++) {
									JsVote vote = new JsVote();
									if (wj.getCity().equals("时间")) {
										if (i == datelist.size() - 1) {
											date = date + datelist.get(i);
										} else {
											date = date + datelist.get(i) + ",";
										}
									} else if (wj.getCity().equals("总问卷")) {
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											zwjCount = zwjCount + count;
										} else {
											zwjCount = zwjCount + count + ",";
										}
									} else if (wj.getCity().equals("当地有中心问卷")) {
										/*
										 * vote.setStartTime(sdf.parse(datelist.get
										 * (i)).getTime()/1000);
										 * vote.setEndTime(
										 * DateUtil.getTommorrowDay1
										 * (sdf.parse(datelist
										 * .get(i))).getTime()/1000); String
										 * count =
										 * voteDao.getVoteCountByLikeDdzx
										 * (vote)+""; if(i==datelist.size()-1){
										 * ddzxCount = ddzxCount + count; }else{
										 * ddzxCount = ddzxCount + count+","; }
										 */
									} else if (wj.getCity().equals("北京")) {
										vote.setCity("北京");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											bjCount = bjCount + count;
										} else {
											bjCount = bjCount + count + ",";
										}
									} else if (wj.getCity().equals("上海")) {
										vote.setCity("上海");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											shCount = shCount + count;
										} else {
											shCount = shCount + count + ",";
										}
									} else if (wj.getCity().equals("深圳")) {
										vote.setCity("深圳");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											szCount = szCount + count;
										} else {
											szCount = szCount + count + ",";
										}
									} else if (wj.getCity().equals("杭州")) {
										vote.setCity("杭州");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											hzCount = hzCount + count;
										} else {
											hzCount = hzCount + count + ",";
										}
									} else if (wj.getCity().equals("南京")) {
										vote.setCity("南京");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											njCount = njCount + count;
										} else {
											njCount = njCount + count + ",";
										}
									} else if (wj.getCity().equals("天津")) {
										vote.setCity("天津");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											tjCount = tjCount + count;
										} else {
											tjCount = tjCount + count + ",";
										}
									} else if (wj.getCity().equals("广州")) {
										vote.setCity("广州");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											gzCount = gzCount + count;
										} else {
											gzCount = gzCount + count + ",";
										}
									} else if (wj.getCity().equals("苏州")) {
										vote.setCity("苏州");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											suzCount = suzCount + count;
										} else {
											suzCount = suzCount + count + ",";
										}
									} else if (wj.getCity().equals("宁波")) {
										vote.setCity("宁波");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											nbCount = nbCount + count;
										} else {
											nbCount = nbCount + count + ",";
										}
									} else if (wj.getCity().equals("无锡")) {
										vote.setCity("无锡");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											wxCount = wxCount + count;
										} else {
											wxCount = wxCount + count + ",";
										}
									} else if (wj.getCity().equals("武汉")) {
										vote.setCity("武汉");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											whCount = whCount + count;
										} else {
											whCount = whCount + count + ",";
										}
									} else if (wj.getCity().equals("长沙")) {
										vote.setCity("长沙");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											csCount = csCount + count;
										} else {
											csCount = csCount + count + ",";
										}
									} else if (wj.getCity().equals("重庆")) {
										vote.setCity("重庆");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											cqCount = cqCount + count;
										} else {
											cqCount = cqCount + count + ",";
										}
									} else if (wj.getCity().equals("成都")) {
										vote.setCity("成都");
										vote.setStartTime(sdf.parse(
												datelist.get(i)).getTime() / 1000);
										vote.setEndTime(DateUtil
												.getTommorrowDay1(
														sdf.parse(datelist
																.get(i)))
												.getTime() / 1000);
										String count = voteDao
												.getVoteCountByLikeCity(vote)
												+ "";
										if (i == datelist.size() - 1) {
											cdCount = cdCount + count;
										} else {
											cdCount = cdCount + count + ",";
										}
									}
								}

								if (wj.getCity().equals("时间")) {
									wj.setContent(date);
								} else if (wj.getCity().equals("总问卷")) {
									wj.setContent(zwjCount);
									result.setDefaultModel("zwjCount", zwjCount);
								} else if (wj.getCity().equals("当地有中心问卷")) {
									wj.setContent(ddzxCount);
								} else if (wj.getCity().equals("北京")) {
									wj.setContent(bjCount);
								} else if (wj.getCity().equals("上海")) {
									wj.setContent(shCount);
								} else if (wj.getCity().equals("深圳")) {
									wj.setContent(szCount);
								} else if (wj.getCity().equals("杭州")) {
									wj.setContent(hzCount);
								} else if (wj.getCity().equals("南京")) {
									wj.setContent(njCount);
								} else if (wj.getCity().equals("天津")) {
									wj.setContent(tjCount);
								} else if (wj.getCity().equals("广州")) {
									wj.setContent(gzCount);
								} else if (wj.getCity().equals("苏州")) {
									wj.setContent(suzCount);
								} else if (wj.getCity().equals("宁波")) {
									wj.setContent(nbCount);
								} else if (wj.getCity().equals("无锡")) {
									wj.setContent(wxCount);
								} else if (wj.getCity().equals("武汉")) {
									wj.setContent(whCount);
								} else if (wj.getCity().equals("长沙")) {
									wj.setContent(csCount);
								} else if (wj.getCity().equals("重庆")) {
									wj.setContent(cqCount);
								} else if (wj.getCity().equals("成都")) {
									wj.setContent(cdCount);
								}
							}

						}
						Integer yicoun = 0, ercoun = 0, sancoun = 0, sicoun = 0, wucoun = 0, liucoun = 0, qicoun = 0, bacoun = 0, jiucoun = 0, shicoun = 0, sycoun = 0;
						Integer sercoun = 0, ssancoun = 0, ssicoun = 0, swucoun = 0, sliucoun = 0, sqcoun = 0, sbcoun = 0, sjcoun = 0, erscoun = 0, esycoun = 0, esesoun = 0;
						Integer esscoun = 0, essicoun = 0, eswcoun = 0, esliucoun = 0, esqcoun = 0, esbcoun = 0, esjcoun = 0, sscoun = 0, ssycoun = 0;
						String ddcount = "";
						for (int j = 3; j < wjList.size(); j++) {
							String[] content = wjList.get(j).getContent()
									.split(",");
							for (int i = 0; i < content.length; i++) {
								if (i == 0) {
									yicoun = yicoun
											+ Integer.valueOf(content[0]);
								} else if (i == 1) {
									ercoun = ercoun
											+ Integer.valueOf(content[1]);
								} else if (i == 2) {
									sancoun = sancoun
											+ Integer.valueOf(content[2]);
								} else if (i == 3) {
									sicoun = sicoun
											+ Integer.valueOf(content[3]);
								} else if (i == 4) {
									wucoun = wucoun
											+ Integer.valueOf(content[4]);
								} else if (i == 5) {
									liucoun = liucoun
											+ Integer.valueOf(content[5]);
								} else if (i == 6) {
									qicoun = qicoun
											+ Integer.valueOf(content[6]);
								} else if (i == 7) {
									bacoun = bacoun
											+ Integer.valueOf(content[7]);
								} else if (i == 8) {
									jiucoun = jiucoun
											+ Integer.valueOf(content[8]);
								} else if (i == 9) {
									shicoun = shicoun
											+ Integer.valueOf(content[9]);
								} else if (i == 10) {
									sycoun = sycoun
											+ Integer.valueOf(content[10]);
								} else if (i == 11) {
									sercoun = sercoun
											+ Integer.valueOf(content[11]);
								} else if (i == 12) {
									ssancoun = ssancoun
											+ Integer.valueOf(content[12]);
								} else if (i == 13) {
									ssicoun = ssicoun
											+ Integer.valueOf(content[13]);
								} else if (i == 14) {
									swucoun = swucoun
											+ Integer.valueOf(content[14]);
								} else if (i == 15) {
									sliucoun = sliucoun
											+ Integer.valueOf(content[15]);
								} else if (i == 16) {
									sqcoun = sqcoun
											+ Integer.valueOf(content[16]);
								} else if (i == 17) {
									sbcoun = sbcoun
											+ Integer.valueOf(content[17]);
								} else if (i == 18) {
									sjcoun = sjcoun
											+ Integer.valueOf(content[18]);
								} else if (i == 19) {
									erscoun = erscoun
											+ Integer.valueOf(content[19]);
								} else if (i == 20) {
									esycoun = esycoun
											+ Integer.valueOf(content[20]);
								} else if (i == 21) {
									esesoun = esesoun
											+ Integer.valueOf(content[21]);
								} else if (i == 22) {
									esscoun = yicoun
											+ Integer.valueOf(content[22]);
								} else if (i == 23) {
									essicoun = yicoun
											+ Integer.valueOf(content[23]);
								} else if (i == 24) {
									eswcoun = yicoun
											+ Integer.valueOf(content[24]);
								} else if (i == 25) {
									esliucoun = yicoun
											+ Integer.valueOf(content[25]);
								} else if (i == 26) {
									esqcoun = yicoun
											+ Integer.valueOf(content[26]);
								} else if (i == 27) {
									esbcoun = yicoun
											+ Integer.valueOf(content[27]);
								} else if (i == 28) {
									esjcoun = yicoun
											+ Integer.valueOf(content[28]);
								} else if (i == 29) {
									sscoun = yicoun
											+ Integer.valueOf(content[29]);
								} else if (i == 30) {
									ssycoun = yicoun
											+ Integer.valueOf(content[30]);
								}
							}
						}
						ddcount = yicoun + "," + ercoun + "," + sancoun + ","
								+ sicoun + "," + wucoun + "," + liucoun + ","
								+ qicoun + "," + bacoun + "," + jiucoun + ","
								+ shicoun + "," + sycoun + "," + sercoun + ","
								+ ssancoun + "," + ssicoun + "," + swucoun
								+ "," + sliucoun + "," + sqcoun + "," + sbcoun
								+ "," + sjcoun + "," + erscoun + "," + esycoun
								+ "," + esesoun + "," + esscoun + ","
								+ essicoun + "," + eswcoun + "," + esliucoun
								+ "," + esqcoun + "," + esbcoun + "," + esjcoun
								+ "," + sscoun + "," + ssycoun;
						CityWenjuan wenj = new CityWenjuan();
						wenj.setCity("当地有中心问卷");
						wenj.setContent(ddcount);
						wjList.set(2, wenj);

						result.setDefaultModel("ddcount", ddcount);
					}

					result.setDefaultModel("wjList", wjList);
				} catch (Exception e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("system/statis/system_wenjuan_statis", modelMap);
	}

	// 及时分配统计--推广部门所有人统计
	@RequestMapping(value = "/system_fenpei_betimes")
	public ModelAndView system_fenpei_betimes(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String nickname = request.getParameter("nickname");
					String startTime = request.getParameter("startTime");
					String endTime = request.getParameter("endTime");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

					if (startTime != null && !"".equals(startTime)) {
					} else {
						startTime = sdf.format(new Date());
					}
					result.setDefaultModel("startTime", startTime);
					result.setDefaultModel("endTime", endTime);

					if (endTime != null && !"".equals(endTime)) {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(endTime)));
					} else {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(startTime)));
					}

					TgUser user = UserUtil.getUserFromCookies();
					if (user == null) {
						return result;
					}

					TgUserinfo userinfo = new TgUserinfo();
					userinfo.setState("1");
					if (nickname != null && !"".equals(nickname)) {
						userinfo.setNickname(nickname);
						result.setDefaultModel("nickname", nickname);
					}
					List<TgUserinfo> infoList = userinfoDao
							.getUserInfoByListState(userinfo);
					if (infoList != null && infoList.size() > 0) {
						for (TgUserinfo info : infoList) {
							TgClientImp clientImp = new TgClientImp();
							clientImp.setUsername(info.getUsername());
							clientImp.setStartTime(startTime);
							clientImp.setEndTime(endTime);
							List<TgClientImp> clientImpList = clientImpDao
									.getClientImpByType(clientImp);
							info.setZonCount(clientImpList.size());
							if (clientImpList != null
									&& clientImpList.size() > 0) {
								Integer yiCount = 0;// 已分配
								Integer weiCount = 0;// 未分配
								Integer sfzCount = 0;// 十分钟内
								Integer bxsCount = 0;// 半个小时内
								Integer gqiCount = 0;// 超过半小时
								for (TgClientImp imp : clientImpList) {
									if (imp.getTo_time() != null
											&& !"".equals(imp.getTo_time())) {
										yiCount++;
										Long time = imp.getTo_time().getTime()
												- imp.getCreate_time()
														.getTime();
										if (time < 600000) {
											sfzCount++;
										} else if (time < 1800000) {
											bxsCount++;
										} else if (time > 1800000) {
											gqiCount++;
										}
									} else {
										weiCount++;
									}
								}
								info.setYiCount(yiCount);
								info.setWeiCount(weiCount);
								info.setSfzCount(sfzCount);
								info.setBxsCount(bxsCount);
								info.setGqiCount(gqiCount);
							}
						}
					}

					result.setDefaultModel("infoList", infoList);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("system/statis/system_fenpei_betimes", modelMap);
	}

	// 资源分配均匀查询--所有咨询师分配情况
	@RequestMapping(value = "/system_fenpei_consu")
	public ModelAndView system_fenpei_consu(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, final HttpServletResponse response)
			throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String nickname = request.getParameter("nickname");
					String startTime = request.getParameter("startTime");
					String endTime = request.getParameter("endTime");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

					if (startTime != null && !"".equals(startTime)) {
					} else {
						startTime = sdf.format(new Date());
					}
					result.setDefaultModel("startTime", startTime);
					result.setDefaultModel("endTime", endTime);

					if (endTime != null && !"".equals(endTime)) {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(endTime)));
					} else {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(startTime)));
					}

					TgUser user = UserUtil.getUserFromCookies();
					if (user == null) {
						return result;
					}

					TgUserinfo userinfo = new TgUserinfo();
					userinfo.setJob("课程顾问");
					if (nickname != null && !"".equals(nickname)) {
						userinfo.setNickname(nickname);
						result.setDefaultModel("nickname", nickname);
					}
					List<TgUserinfo> infoList = userinfoDao
							.getUserInfoByUserInfo(userinfo);
					if (infoList != null && infoList.size() > 0) {
						for (TgUserinfo info : infoList) {
							TgClientImp clientImp = new TgClientImp();
							clientImp.setTo_username(info.getUsername());
							clientImp.setStartTime(startTime);
							clientImp.setEndTime(endTime);
							Integer count = clientImpDao
									.getClientImpCountByType(clientImp);
							info.setZonCount(count);
						}
					}

					result.setDefaultModel("infoList", infoList);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("system/statis/system_fenpei_consu", modelMap);
	}

	// 及时跟踪将--所有咨询师跟踪情况情况
	@RequestMapping(value = "/system_genzong_consu")
	public ModelAndView system_genzong_consu(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String nickname = request.getParameter("nickname");
					String startTime = request.getParameter("startTime");
					String endTime = request.getParameter("endTime");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

					if (startTime != null && !"".equals(startTime)) {
					} else {
						startTime = sdf.format(new Date());
					}
					result.setDefaultModel("startTime", startTime);
					result.setDefaultModel("endTime", endTime);

					if (endTime != null && !"".equals(endTime)) {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(endTime)));
					} else {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(startTime)));
					}

					TgUser user = UserUtil.getUserFromCookies();
					if (user == null) {
						return result;
					}

					TgUserinfo userinfo = new TgUserinfo();
					userinfo.setJob("课程顾问");
					if (nickname != null && !"".equals(nickname)) {
						userinfo.setNickname(nickname);
						result.setDefaultModel("nickname", nickname);
					}
					List<TgUserinfo> infoList = userinfoDao
							.getUserInfoByUserInfo(userinfo);
					List<String> timelist = DateUtil.printWeekdays(startTime);// 获取本周时间
					if (infoList != null && infoList.size() > 0) {
						for (TgUserinfo info : infoList) {
							TgClientImp clientImp = new TgClientImp();
							clientImp.setTo_username(info.getUsername());
							clientImp.setTo_startTime(startTime);
							clientImp.setTo_endTime(endTime);
							List<TgClientImp> clientImpList = clientImpDao
									.getClientImpByType(clientImp);
							info.setTodayzonCount(clientImpList.size());
							if (clientImpList != null
									&& clientImpList.size() > 0) {
								Integer tweigzCount = 0;// 今日资源未跟踪数量
								Integer todayweigzCount = 0;// 今日资源今日未跟踪数量
								for (TgClientImp imp : clientImpList) {
									TgTracking tracking = new TgTracking();
									tracking.setClient(imp.getKeyname());
									List<TgTracking> tralist = trackingDao
											.findByExample(tracking);
									if (tralist != null && tralist.size() > 0) {
										if (!sdf.format(
												new Date(tralist.get(0)
														.getCdate() * 1000))
												.equals(startTime)) {
											todayweigzCount++;
										}
									} else {
										tweigzCount++;
									}
								}
								info.setTweigzCount(tweigzCount);
								info.setTodayweigzCount(todayweigzCount);
							}

							if (timelist != null && timelist.size() > 0) {
								TgClientImp clientImp2 = new TgClientImp();
								clientImp2.setTo_username(info.getUsername());
								clientImp2.setTo_startTime(timelist.get(0));
								clientImp2.setTo_endTime(timelist.get(timelist
										.size() - 1));
								List<TgClientImp> clientImpList2 = clientImpDao
										.getClientImpByType(clientImp2);
								info.setWeekzonCount(clientImpList2.size());
								if (clientImpList2 != null
										&& clientImpList2.size() > 0) {
									Integer bweigzCount = 0;// 本周资源未跟踪数量
									Integer weekweigzCount = 0;// 本周资源今日未跟踪数量
									for (TgClientImp imp2 : clientImpList2) {
										TgTracking tracking = new TgTracking();
										tracking.setClient(imp2.getKeyname());
										List<TgTracking> tralist = trackingDao
												.findByExample(tracking);
										if (tralist != null
												&& tralist.size() > 0) {
											if (!sdf.format(
													new Date(tralist.get(0)
															.getCdate() * 1000))
													.equals(startTime)) {
												weekweigzCount++;
											}
										} else {
											bweigzCount++;
										}
									}
									info.setBweigzCount(bweigzCount);
									info.setWeekweigzCount(weekweigzCount);
								}
							}

						}
					}

					result.setDefaultModel("infoList", infoList);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("system/statis/system_genzong_consu", modelMap);
	}

	// 渠道资源转化率分析
	@RequestMapping(value = "/system_qudao_zhuanhua")
	public ModelAndView system_qudao_zhuanhua(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String source = request.getParameter("source");
					String startTime = request.getParameter("startTime");
					String endTime = request.getParameter("endTime");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

					if (startTime != null && !"".equals(startTime)) {
					} else {
						startTime = sdf.format(new Date());
					}

					if (endTime != null && !"".equals(endTime)) {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(endTime)));
					} else {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(startTime)));
					}

					TgUser user = UserUtil.getUserFromCookies();
					if (user == null) {
						return result;
					}

					List<String> timelist = DateUtil.printWeekdays(startTime);// 获取本周时间
					result.setDefaultModel("startTime", startTime);
					result.setDefaultModel("endTime",
							timelist.get(timelist.size() - 1));
					TgSource sour = new TgSource();
					if (source != null && !"".equals(source)) {
						sour.setKeyname(source);
					}
					List<TgSource> list = sourceDao.findByExample(sour);
					result.setDefaultModel("soulist", list);
					if (list != null && list.size() > 0) {
						for (TgSource sou : list) {
							TgClientImp clientImp = new TgClientImp();
							clientImp.setType(sou.getKeyname());
							clientImp.setStartCTime(timelist.get(0));
							clientImp.setEndCTime(timelist.get(timelist.size() - 1));
							List<TgClientImp> impList = clientImpDao
									.getClientImpByType(clientImp);
							sou.setZonCount(impList.size() + "");// 资源总数
							if (impList != null && impList.size() > 0) {

								Integer yxCount = 0;
								Integer yyCount = 0;
								Integer cepCount = 0;
								for (TgClientImp imp : impList) {
									// 资源有效量和有效率
									TgClient client = new TgClient();
									if (user.getUsergroup() == 3) {
										client.setUsername(user.getUsername());
									}
									client.setKeyname(imp.getKeyname());
									client.setInvalid(1);
									Long clientCount = clientDao
											.countEqual(client);
									if (clientCount > 0) {
										yxCount++;
									}

									// 资源预约数量和预约率
									TgReserve reserve = new TgReserve();
									if (user.getUsergroup() == 3) {
										reserve.setUsername(user.getUsername());
									}
									reserve.setClient(imp.getKeyname());
									Long resCount = reserveDao
											.countEqual(reserve);
									if (resCount > 0) {
										yyCount++;
									}

									// 测评数量和到访率
									TgReception reception = new TgReception();
									if (user.getUsergroup() == 3) {
										reception.setUsername(user
												.getUsername());
									}
									reception.setClient(imp.getKeyname());
									Long receCount = receptionDao
											.countEqual(reception);
									if (receCount > 0) {
										cepCount++;
									}
								}
								Integer youxiaolv = yxCount / impList.size();
								Integer yuyuelv = yyCount / impList.size();
								Integer cepinglv = cepCount / impList.size();

								sou.setYxCount(yxCount);
								sou.setYuyuelv(youxiaolv);
								sou.setYyCount(yyCount);
								sou.setYuyuelv(yuyuelv);
								sou.setCpCount(cepCount);
								sou.setCepinglv(cepinglv);
							}
						}
					}
					result.setDefaultModel("list", list);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("system/statis/system_qudao_zhuanhua", modelMap);
	}

	// 竞价渠道信息量统计分析
	@RequestMapping(value = "/system_jingjia_statis")
	public ModelAndView system_jingjia_statis(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String startTime = request.getParameter("startTime");
					String endTime = request.getParameter("endTime");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

					if (startTime != null && !"".equals(startTime)) {
					} else {
						startTime = sdf.format(new Date());
					}
					result.setDefaultModel("startTime", startTime);
					result.setDefaultModel("endTime", endTime);

					if (endTime != null && !"".equals(endTime)) {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(endTime)));
					} else {
						endTime = sdf.format(DateUtil.getTommorrowDay1(sdf
								.parse(startTime)));
					}

					TgUser user = UserUtil.getUserFromCookies();
					if (user == null) {
						return result;
					}

					// 根据渠道筛选
					TgSource source = new TgSource();
					source.setType("sq");
					List<TgSource> list = sourceDao.findByExample(source);
					if (list != null && list.size() > 0) {
						for (TgSource sour : list) {
							Integer jdsCount = 0; // 09:00-10:00
							Integer sdsyCount = 0; // 10:00-11:00
							Integer sydseCount = 0; // 11:00-12:00
							Integer sedssCount = 0; // 12:00-13:00
							Integer ssdssCount = 0; // 13:00-14:00
							Integer ssdswCount = 0; // 14:00-15:00
							Integer swdslCount = 0; // 15:00-16:00
							Integer sldsqCount = 0; // 16:00-17:00
							Integer sqdsbCount = 0; // 17:00-18:00
							Integer sbdsjCount = 0; // 18:00-19:00
							Integer sjdesCount = 0; // 19:00-20:00
							Integer esdesyCount = 0; // 20:00-21:00
							Integer esydeseCount = 0; // 21:00-22:00
							Integer esedessCount = 0; // 22:00-23:00
							Integer essdjiuCount = 0; // 23:00-09:00

							TgClientImp clientimp = new TgClientImp();
							clientimp.setType(sour.getKeyname());
							List<TgClientImp> impList = clientImpDao
									.findByExample(clientimp);
							if (impList != null && impList.size() > 0) {
								for (TgClientImp imp : impList) {
									String fw_start = imp.getFw_start();
									if (fw_start != null
											&& !"".equals(fw_start)
											&& fw_start.length() > 10) {
										fw_start = fw_start.substring(12, 14);
										Integer start = Integer
												.valueOf(fw_start);
										if (start == 9) {
											jdsCount++;
										} else if (start == 10) {
											sdsyCount++;
										} else if (start == 11) {
											sydseCount++;
										} else if (start == 12) {
											sedssCount++;
										} else if (start == 13) {
											ssdssCount++;
										} else if (start == 14) {
											ssdswCount++;
										} else if (start == 15) {
											swdslCount++;
										} else if (start == 16) {
											sldsqCount++;
										} else if (start == 17) {
											sqdsbCount++;
										} else if (start == 18) {
											sbdsjCount++;
										} else if (start == 19) {
											sjdesCount++;
										} else if (start == 20) {
											esdesyCount++;
										} else if (start == 21) {
											esydeseCount++;
										} else if (start == 22) {
											esedessCount++;
										} else {
											essdjiuCount++;
										}
									}
								}
							}
							sour.setJdsCount(jdsCount);
							sour.setSdsyCount(sdsyCount);
							sour.setSydseCount(sydseCount);
							sour.setSedssCount(sedssCount);
							sour.setSsdssCount(ssdssCount);
							sour.setSsdswCount(ssdswCount);
							sour.setSwdslCount(swdslCount);
							sour.setSldsqCount(sldsqCount);
							sour.setSqdsbCount(sqdsbCount);
							sour.setSbdsjCount(sbdsjCount);
							sour.setSjdesCount(sjdesCount);
							sour.setEsdesyCount(esdesyCount);
							sour.setEsydeseCount(esydeseCount);
							sour.setEsedessCount(esedessCount);
							sour.setEssdjiuCount(essdjiuCount);
						}
					}

					// 根据时间筛选
					List<String> strList = Constants.timeMap;
					List<JingJia> jjiaList = new ArrayList<JingJia>();
					if (strList != null && strList.size() > 0) {
						for (int i = 0; i < strList.size(); i++) {
							JingJia jjia = new JingJia();
							jjia.setTime(strList.get(i));
							jjiaList.add(jjia);
						}
					}

					if (jjiaList != null && jjiaList.size() > 0) {
						for (JingJia jjia : jjiaList) {
							TgSource sources = new TgSource();
							sources.setType("sq");
							List<TgSource> soulist = sourceDao
									.findByExample(sources);
							if (soulist != null && soulist.size() > 0) {
								for (int i = 0; i < soulist.size(); i++) {
									TgClientImp clientimp = new TgClientImp();
									clientimp.setFw_start(jjia.getTime());
									clientimp.setType(soulist.get(i)
											.getKeyname());
									Integer count = clientImpDao
											.getClientImpByLikeFwTime(clientimp);
									if (i == 0) {
										jjia.setCount1(count);
									} else if (i == 1) {
										jjia.setCount2(count);
									} else if (i == 2) {
										jjia.setCount3(count);
									} else if (i == 3) {
										jjia.setCount4(count);
									} else if (i == 4) {
										jjia.setCount5(count);
									} else if (i == 5) {
										jjia.setCount6(count);
									} else if (i == 6) {
										jjia.setCount7(count);
									} else if (i == 7) {
										jjia.setCount8(count);
									} else if (i == 8) {
										jjia.setCount9(count);
									} else if (i == 9) {
										jjia.setCount10(count);
									}
								}
							}

						}
					}
					result.setDefaultModel("jjiaList", jjiaList);
					result.setDefaultModel("list", list);
				} catch (ParseException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("system/statis/system_jingjia_statis", modelMap);
	}

	// 获取竞价渠道信息量统计
	@RequestMapping(value = "/getjingjia")
	public ModelAndView system_reserve_del(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, HttpServletResponse response)
			throws BaseException {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String date = request.getParameter("date");
					SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");

					List<String> qdlist = new ArrayList<String>();
					List<String> qdyuelist = new ArrayList<String>();

					TgSource source = new TgSource();
					source.setType("1");
					List<TgSource> soulist = sourceDao.findByExample(source);

					if (date == null || date.equals("")) {
						date = sd.format(new Date());
					}
					List<String> list = DateUtil.getdatebymonth(date);
					TgClient client = new TgClient();
					if (soulist != null && soulist.size() > 0) {
						for (TgSource s : soulist) {
							// 每天统计
							for (int i = 0; i < list.size(); i++) {
								client.setSource(s.getKeyname());
								client.setStartTime(sdf.parse(list.get(i))
										.getTime() / 1000);
								client.setEndTime(DateUtil.getTommorrowDay1(
										sdf.parse(list.get(i))).getTime() / 1000);
								List<TgClient> clist = clientDao.getClientCityByType(client);
								if (clist != null && clist.size() > 0) {
									HashMap<String, Integer> hs = new HashMap<String, Integer>();
									for (TgClient c : clist) {
										Integer count = 1;
										if (c.getProvince() != null) {
											if (c.getProvince().equals("上海")
													|| c.getProvince().equals(
															"北京")
													|| c.getProvince().equals(
															"天津")
													|| c.getProvince().equals(
															"重庆")) {
												if (hs.get(c.getProvince()) != null) {
													count = hs.get(c
															.getProvince()) + 1;
												}
												hs.put(c.getProvince(), count);
											} else {
												if (hs.get(c.getCity()) != null) {
													count = hs.get(c.getCity()) + 1;
												}
												hs.put(c.getCity(), count);
											}
										} else {
											if (hs.get(c.getCity()) != null) {
												count = hs.get(c.getCity()) + 1;
											}
											hs.put(c.getCity(), count);
										}

									}

									qdlist.add(s.getName() + ":" + list.get(i)
											+ ":" + hs);
								}
							}

							// 每月统计
							client.setSource(s.getKeyname());
							client.setStartTime(sdf.parse(list.get(0))
									.getTime() / 1000);
							client.setEndTime(DateUtil.getTommorrowDay1(
									sdf.parse(list.get(list.size() - 1)))
									.getTime() / 1000);
							List<TgClient> clist = clientDao.getClientCityByType(client);
							if (clist != null && clist.size() > 0) {
								HashMap<String, Integer> hs = new HashMap<String, Integer>();
								for (TgClient c : clist) {
									Integer count = 1;
									if (c.getProvince() != null) {
										if (c.getProvince().equals("上海")
												|| c.getProvince().equals("北京")
												|| c.getProvince().equals("天津")
												|| c.getProvince().equals("重庆")) {
											if (hs.get(c.getProvince()) != null) {
												count = hs.get(c.getProvince()) + 1;
											}
											hs.put(c.getProvince(), count);
										} else {
											if (hs.get(c.getCity()) != null) {
												count = hs.get(c.getCity()) + 1;
											}
											hs.put(c.getCity(), count);
										}
									} else {
										if (hs.get(c.getCity()) != null) {
											count = hs.get(c.getCity()) + 1;
										}
										hs.put(c.getCity(), count);
									}

								}
								qdyuelist.add(s.getName() + ":当月:" + hs);
							}
						}
					}

					result.setDefaultModel("qdlist", qdlist);
					result.setDefaultModel("qdyuelist", qdyuelist);
					result.setDefaultModel("date", date);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("system/statis/system_qudao_city", modelMap);
	}

	// 咨询接待统计
	@RequestMapping(value = "/system_reception_statis")
	public ModelAndView system_reception_statis(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String stat = request.getParameter("startTime");
				String end = request.getParameter("endTime");

				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				TgUserinfo user = new TgUserinfo();
				user.setJob("课程顾问");
				if (stat == null || "".equals(stat)) {
					Calendar date = Calendar.getInstance();
					date.setTime(new Date());
					date.set(Calendar.DATE, date.get(Calendar.DATE) - 7);
					Date endDate = null;
					try {
						endDate = sdf.parse(sdf.format(date.getTime()));
					} catch (ParseException e) {
						e.printStackTrace();
					}

					List<String> timelist = DateUtil.printWeekdays(sdf
							.format(endDate));
					stat = timelist.get(0);
					end = timelist.get(timelist.size() - 1);
				}

				Integer total = userinfoDao.getUsernameCont(user);
				Page page = PageUtil.createPage(total, 1, total);
				List<TgUserinfo> list = userinfoDao.getUserInfoUsername(user,page);

				float mary_sum = 0;
				int mary_zon = 0;
				int mary_fei = 0;
				int mary_zonear = 0;
				float mary_sum1 = 0;
				int mary_zonshichang = 0;

				DecimalFormat fnum = new DecimalFormat("#.##%");
				DecimalFormat fnu = new DecimalFormat("#.##");

				if (list != null && list.size() > 0) {
					try {
						TgReception rece = new TgReception();
						TgReception rece1 = new TgReception();
						for (TgUserinfo use : list) {
							if(use.getUsername().equals("he") || use.getUsername().equals("zhanglong")){
								
							}
							rece.setUsername(use.getUsername());
							rece.setStartTime(sdf.parse(stat).getTime() / 1000);
							rece.setEndTime(sdf.parse(end).getTime() / 1000);

							rece1.setUsername(use.getUsername());
							rece1.setStartTime(sdf.parse(stat).getTime() / 1000);
							rece1.setEndTime(sdf.parse(end).getTime() / 1000);
							rece1.setC_keyname("市场部推广，传单派发，公益讲座");

							List<TgReception> reslist = receptionDao
									.getMoneyEar(rece);
							List<TgReception> ear = receptionDao
									.getEarnest(rece);
							List<TgReception> earlist = receptionDao
									.getEarnest1(rece);

							List<TgReception> reslist1 = receptionDao
									.getMoneyEar(rece1);
							List<TgReception> ear1 = receptionDao
									.getEarnest(rece1);
							List<TgReception> earlist1 = receptionDao
									.getEarnest1(rece1);

							// 总的接待量
							Integer zonRece = receptionService.getZonlReceptionCount(rece);
							// 市场的接待量
							Integer zonear = receptionDao
									.getZonlEarnestCount(rece1);

							// 总业绩
							float sum = (float) 0;
							int zondan = 0;
							if (ear != null && !"".equals(ear)) {
								for (int i = 0; i < ear.size(); i++) {
									if (ear.get(i).getEarnest_date() != null) {
										if (sdf.parse(stat).getTime() / 1000 <= ear
												.get(i).getEarnest_date()
												&& ear.get(i).getEarnest_date() <= sdf
														.parse(end).getTime() / 1000) {
											if (ear.get(i).getMoney() != null) {
												sum += ear.get(i).getMoney();
											} else if (ear.get(i).getEarnest() != null) {
												sum += ear.get(i).getEarnest();
											}
											zondan += 1;
										} else if (ear.get(i).getMoney() != null
												&& ear.get(i).getEarnest() != null) {
											sum += ear.get(i).getMoney()
													- ear.get(i).getEarnest();
										}
									} else if (ear.get(i).getEarnest_date() == null
											&& ear.get(i).getMoney() != null) {
										sum += ear.get(i).getMoney();
										zondan += 1;
									}

								}
							}
							if (reslist != null && !"".equals(reslist)) {
								for (int i = 0; i < reslist.size(); i++) {
									if (reslist.get(i).getMoney1() != null) {
										sum += reslist.get(i).getMoney1();
									}
								}
							}
							if (earlist != null && !"".equals(earlist)) {
								for (int i = 0; i < earlist.size(); i++) {
									if (earlist.get(i).getRep_date() == null) {
										if (earlist.get(i).getEarnest() != null) {
											sum += earlist.get(i).getEarnest();
											zondan += 1;
										}
									} else if (sdf.parse(end).getTime() / 1000 <= earlist
											.get(i).getRep_date()) {
										sum += earlist.get(i).getEarnest();
										zondan += 1;
									}
								}
							}
							// 市场业绩
							float sum1 = (float) 0;
							int zonshichang = 0;
							if (ear1 != null && !"".equals(ear1)) {
								for (int i = 0; i < ear1.size(); i++) {
									if (ear1.get(i).getEarnest_date() != null) {
										if (sdf.parse(stat).getTime() / 1000 <= ear1
												.get(i).getEarnest_date()
												&& ear1.get(i)
														.getEarnest_date() <= sdf
														.parse(end).getTime() / 1000) {
											if (ear1.get(i).getMoney() != null) {
												sum1 += ear1.get(i).getMoney();
											} else if (ear.get(i).getEarnest() != null) {
												sum1 += ear1.get(i)
														.getEarnest();
											}
											zonshichang += 1;
										} else if (ear1.get(i).getMoney() != null
												&& ear1.get(i).getEarnest() != null) {
											sum1 += ear1.get(i).getMoney()
													- ear1.get(i).getEarnest();
										}
									} else if (ear1.get(i).getEarnest_date() == null
											&& ear1.get(i).getMoney() != null) {
										sum1 += ear1.get(i).getMoney();
										zonshichang += 1;
									}
								}
							}
							if (reslist1 != null && !"".equals(reslist1)) {
								for (int i = 0; i < reslist1.size(); i++) {
									if (reslist1.get(i).getMoney1() != null) {
										sum1 += reslist1.get(i).getMoney1();
									}
								}
							}
							if (earlist1 != null && !"".equals(earlist1)) {
								for (int i = 0; i < earlist1.size(); i++) {
									if (earlist1.get(i).getRep_date() == null) {
										if (earlist1.get(i).getEarnest() != null) {
											sum += earlist1.get(i).getEarnest();
											zonshichang += 1;
										}
									} else if (sdf.parse(end).getTime() / 1000 <= earlist1
											.get(i).getRep_date()) {
										sum += earlist1.get(i).getEarnest();
										zonshichang += 1;
									}
								}
							}
							// 非市场业绩
							float sum3 = sum - sum1;
							// 非市场的接待量
							int zon = zonRece - zonear;
							// 非市场的成单
							int fei = zondan - zonshichang;

							mary_sum = mary_sum + sum3;
							mary_zon = mary_zon + zon;
							mary_fei = mary_fei + fei;
							mary_zonear = mary_zonear + zonear;
							mary_sum1 = mary_sum1 + sum1;
							mary_zonshichang = mary_zonshichang + zonshichang;

							use.setFeisum(String.valueOf(sum3));
							use.setShisum(String.valueOf(sum1));
							use.setZonrece(zon);
							use.setZonear(zonear);
							use.setFeizon(fei);
							use.setZonchen(zonshichang);

							if (zon != 0 && fei != 0) {
								float rese = (float) fei / zon;
								String feichenrate = fnum.format(rese);
								use.setFeichenrate(feichenrate);
								use.setRates(Double.valueOf(rese));
							} else {
								String che = "0";
								use.setFeichenrate(che);
								use.setRates(Double.valueOf(che));

							}

							if (zonear != 0 && zonshichang != 0) {
								float rese = (float) zonshichang / zonear;
								String chenrate = fnum.format(rese);
								use.setChenrate(chenrate);
							} else {
								String che = "0";
								use.setChenrate(che);
							}

							if (sum3 != 0 && zon != 0) {
								float rese = (float) sum3 / zon;
								String sumrate = fnu.format(rese);
								use.setSumrate(sumrate);
							} else {
								String che = "0";
								use.setSumrate(che);
							}
						}

					} catch (ParseException e) {
						e.printStackTrace();
					}
				}

				result.setDefaultModel("page", page);

				result.setDefaultModel("list", list);
				result.setDefaultModel("mary_sum", mary_sum);
				result.setDefaultModel("mary_zon", mary_zon);
				result.setDefaultModel("mary_fei", mary_fei);
				result.setDefaultModel("mary_zonear", mary_zonear);
				result.setDefaultModel("mary_sum1", mary_sum1);
				result.setDefaultModel("mary_zonshichang", mary_zonshichang);
				result.setDefaultModel("startTime", stat);
				result.setDefaultModel("endTime", end);
				return result;
			}
		});
		return new ModelAndView("system/statis/system_reception_statis",
				modelMap);
	}
	
	public static void main(String[] args) throws ParseException {
		String fw_start = "2016年08月20日 09时19分04秒";
		fw_start = fw_start.substring(12, 14);
		System.out.println(fw_start);

		List<String> l = new ArrayList<String>();
		l.add("a");
		l.add("a");
		l.add("b");
		l.add("b");
		l.add("b");
		l.add("c");
		l.add("d");
		l.add("d");
		HashMap<String, Integer> hs = new HashMap<String, Integer>();
		for (String string : l) {
			Integer count = 1;
			if (hs.get(string) != null) {
				count = hs.get(string) + 1;
			}
			hs.put(string, count);
		}
		System.out.println(hs);
		System.out.print("重复的有:");
		for (String key : hs.keySet()) {
			if (hs.get(key) != null & hs.get(key) > 1) {
				System.out.print(key + " ");
			}
		}
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		try {
			System.out.println(sdf.parse(sdf.format(DateUtil.getMonthFirst(sdf.format(new Date())))).getTime()/1000);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
}
